python - 列在 DataFrame.info() 中不可见
问题描述
我有以下称为 large5 的 DataFrame:
country United Arab Emirates Djibouti Andorra Saudi Arabia Marshall Islands
1971-1980 NaN NaN NaN NaN NaN
1981-1990 1.082990 0.686978 0.370541 0.603019 0.410776
1991-2000 0.738127 0.366770 0.335852 0.370899 0.225249
2001-2010 1.270588 0.208094 0.255028 0.296046 0.097677
2011-2020 0.254555 -0.078750 -0.212721 0.025291 -0.165853
diff 0.828435 0.765728 0.583262 0.577727 0.576628
在运行large5.info()
时,我无法查看“国家”列,因此无法重命名或在我的可视化中使用它
<class 'pandas.core.frame.DataFrame'>
Index: 6 entries, 1971-1980 to diff
Data columns (total 5 columns):
United Arab Emirates 5 non-null float64
Djibouti 5 non-null float64
Andorra 5 non-null float64
Saudi Arabia 5 non-null float64
Marshall Islands 5 non-null float64
dtypes: float64(5)
memory usage: 288.0+ bytes
运行large5.reset_index(inplace=True)
也不起作用,因为列名更改为“索引”,我无法重命名它或在我的可视化中正确使用它。任何建议,将不胜感激。
解决方案
largenew = large5.rename_axis('Date').reset_index()
推荐阅读
- c++ - 类中成员函数模板的显式实例化
- java - 通过 TestNG 使用 Selenium 执行自动化测试时出现“TestNG No tests found. nothing was run”
- sql - 获取远程服务器版本 MS SQL
- python - 无法使用 sqlacodegen 连接到架构
- java - Quartz 1.6 作业状态处于阻塞状态
- c# - 如何展平通过转换 JSON 创建的 XML
- automationanywhere - AutomationAnywhere:有没有办法将 botstore 中的机器人视为流程?
- list - 在 KDB 中是否有等效于 `inter` 的`outer` 或`exclusive or` 运算符?
- android - 我无法将从 Firebase 检索到的图像加载到 viewpager
- ruby - 当直接调用 .rb 文件时,Bundler 工作,当从其他 ruby 脚本通过 exec 调用时失败