python - 设置 nan 值数据框时的警告
问题描述
想象一下,您有以下 df:
dffinalselection= pd.DataFrame(np.array([[1, np.nan, np.nan], [4, 5, 6], [7, 8, 9]]),
columns=['description#1', 'Party', 'Factuurdatum'])
使用此代码,我试图填充 nan 值:
dffinalselection.loc[dffinalselection['description#1'].isna() == True, 'description#1'] = dffinalselection['Party'] + " " dffinalselection['Factuurdatum']
但是,收到警告:
c:\python38\lib\site-packages\pandas\core\indexing.py:1745: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
isetter(ilocs[0], value)
如何减轻此警告?
看起来不太好看。
请帮忙!
解决方案
推荐阅读
- php - 如何根据以下条件对数字进行四舍五入
- php - 将参数传递给字符串
- shell - neo4j 无法在来自 cypher shell 的 5000 毫秒消息中建立连接
- c# - 删除损坏的 user.config 而不是 System.ConfigurationErrorException
- python - 如何将 QComboBox 中的文本存储在全局变量中
- linux - 在 Linux 上使用 .net 核心更改 IP 地址
- c - 如何检测同时按下按钮
- javascript - Json 对象到网络图的数组
- jquery - Rails + JQuery 侧边栏下拉菜单立即关闭
- php - 如何在mysql中关系数据的每个父记录上选择n个记录子记录