【发布时间】:2019-12-03 08:18:22
【问题描述】:
我有一个包含几列的数据框,其中是性别(男性,女性)。我想得到两个变量与第三个变量的折线图,在这种情况下是收入,我有以下代码:
ax = plt.gca()
df.plot(kind='line', x='income', y=[df.gender=='male'], ax=ax)
df.plot(kind='line', x='income', y=[df.gender =='female'], color='red', ax=ax)
plt.show()
而且我不断收到值错误。 我想我应该使用条形图?? 有什么想法吗?
【问题讨论】:
-
尝试将其更改为
df[df.gender =='male'].plot(x='income', y='your_field)`