pandas - 如何从我的熊猫表中创建特定行的折线图?
问题描述
PARENT Week Month Weekend
---------------------------------------
1010D AX1 665 1633 687
1009A BX1 1372 1484 1173
1013B CX1 895 941 777
1007B DX1 829 932 773
这是我的 mydata.csv。(抱歉,我无法使用 stackoverflow 格式对齐特定列下的行值。@glhr
如何使用 Pandas 在NAME列下为 Week、Month 和 Weekend 的值绘制 BX1 的折线图?
解决方案
If only unique value BX1
value after filtering by boolean indexing
transpose and add DataFrame.squeeze
for convert one column DataFrame
to Series
and plot by plot.bar
:
df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot.bar()
Or:
df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot()
推荐阅读
- django - django 说没有名为“profiles.forms”的模块,但已经创建了它
- python - 使用 xpath 从属性中提取属性 id
- python - Plotly Dash:删除默认的白色图形背景
- java - Bukkit 聊天可点击按钮
- php - 处理 WPform 字段输入的自定义 PHP 代码
- python-3.x - 如何设置 django 管理面板不从 aws s3 加载 css,而是从默认值加载?
- python - 如何在numpy中实现两层Keras conv1d?
- python - 移动 auc 曲线的曲线图例
- python - 获取返回空字典的存储 blob 的属性
- mapbox-gl-js - 有没有办法结合两个光栅mapbox layears