【发布时间】:2022-01-18 08:06:44
【问题描述】:
当我在 python 中编写该行时,我遇到了 juputer notebook 的问题
df["AQI"] = df["AQI"].fillna(round(df[["PM2.5_SubIndex", "PM10_SubIndex", "SO2_SubIndex", "NOx_SubIndex","NH3_SubIndex", " CO_SubIndex", "O3_SubIndex"]].max(axis = 1)))
整个项目在这里: here
错误是:
**KeyError Traceback(最近一次调用最后一次) ~\AppData\Local\Temp/ipykernel_6320/515642622.py 在 ----> 1 default["AQI"] = default["AQI"].fillna(round(default[["PM2.5_SubIndex", "PM10_SubIndex", "SO2_SubIndex", "NOx_SubIndex","NH3_SubIndex", " CO_SubIndex", "O3_SubIndex"]].max(axis = 1))) 2 ~\miniconda3\lib\site-packages\pandas\core\frame.py in getitem(self, key) 第3462章 第3463章 -> 3464 索引器 = self.loc._get_listlike_indexer(key, axis=1)1 3465 3466 # take() 不接受布尔索引器 ~\miniconda3\lib\site-packages\pandas\core\indexing.py in _get_listlike_indexer(self, key, axis) 第1312章 1313 -> 1314 self._validate_read_indexer(keyarr,索引器,轴) 1315 第1316章 ~\miniconda3\lib\site-packages\pandas\core\indexing.py in _validate_read_indexer(self, key, indexer, axis) 1372 如果使用_interval_msg: 第1373章 -> 1374 raise KeyError(f"[{key}] 中没有 [{axis_name}]") 1375 第1376章
和关键错误
KeyError: "没有 [Index(['PM2.5_SubIndex', 'PM10_SubIndex', 'SO2_SubIndex', 'NOx_SubIndex',\n 'NH3_SubIndex', 'CO_SubIndex', 'O3_SubIndex'],\n dtype='对象')]在[列]"
谁能给我解释一下错误是什么以及如何解决它
【问题讨论】:
标签: python pandas jupyter-notebook