我在下面的代码中使用 iloc 方法删除了前两列,没有任何问题。
eng_df.drop(eng_df.iloc[:,:2] , axis=1, inplace=True)
Run Code Online (Sandbox Code Playgroud)
但我尝试使用以下代码中的 iloc 方法删除第一行,但没有成功:
eng_df.drop(eng_df.iloc[:1 , :] , inplace=True)
Run Code Online (Sandbox Code Playgroud)
...并收到以下警告:
KeyError:“['国家''能源供应''人均能源供应''可再生能源百分比']在轴中找不到”
我知道我可以用不同的方式删除行,但我的问题是我可以使用 iloc 方法删除行吗?如果可以,我该怎么做以及我的代码中有什么问题?谢谢...
pandas ×1