我如何从 PANDAS 中的 table 创建特定行的折线图?
How can i create a line chart of a specific row from my table in 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。 (抱歉,我无法对齐特定列下的行值,以 Whosebug 格式询问问题。@glhr
如何使用 Pandas 在 NAME 列下为周、月和周末的值绘制 BX1 的折线图?
如果只有唯一值 BX1
过滤后的值 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()
或者:
df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot()
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。 (抱歉,我无法对齐特定列下的行值,以 Whosebug 格式询问问题。@glhr
如何使用 Pandas 在 NAME 列下为周、月和周末的值绘制 BX1 的折线图?
如果只有唯一值 BX1
过滤后的值 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()
或者:
df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot()