我的程序中的df恰好是一个包含以下列的数据帧:
df.columns
'''output : Index(['lat', 'lng', 'desc', 'zip', 'title', 'timeStamp', 'twp', 'addr', 'e',
'reason'],
dtype='object')'''
当我执行这段代码时:
sns.countplot(x = df['reason'], data=df)
# output is the plot below
但如果我稍微像这样调整代码:
p = df['reason'].value_counts()
k = pd.DataFrame({'causes':p.index,'freq':p.values})
sns.countplot(x = k['causes'], data = k)
所以本质上我只是把“reasons”列的值和它的频率作为一个序列存储在p中,然后把它们转换成另一个数据帧k,但是这个新的countplot对于给定的值没有正确的Y轴范围。你知道吗
我的疑问是:
目前没有回答
相关问题 更多 >
编程相关推荐