python-3.x - 使用 matplotlib 或 seaborn 绘制两列之间的关系

标签 python-3.x pandas matplotlib seaborn

我的数据框中有两列。日期格式的列之一。另一列有 1's 和 0's 。我想绘制一个图表来显示两列之间的关系。这是我的一小段数据

Date received   Consumer disputed?
15-05-2014  0
18-09-2014  0
13-03-2014  0
17-07-2015  1
20-11-2014  0
26-06-2014  0
28-09-2012  0
06-05-2015  1
25-02-2013  0
30-03-2016  0
21-03-2014  0

情节应该是 1 和 0 相对于日期的分布,特别是月份部分,这样我就可以决定哪个月份有更多 1,哪个月份有更多 0。提前致谢

最佳答案

我会使用条形图

df['Consumer disputed?'].groupby(df['Date received'].dt.month).sum().plot.bar()

enter image description here

关于python-3.x - 使用 matplotlib 或 seaborn 绘制两列之间的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46046903/

相关文章:

python - 值错误: ('Series lengths must match to compare' when Using Pandas Style

python - 将光标添加到 matplotlib

python - 如何绘制 Python 3 维水平集?

Python 对多个文本文件中的某些值求和

python-3.x - Docker 名称错误 : name 'app' is not defined

python-3.x - 如何检查哪个pytest标记是运行的测试

python - 查找每行具有第二个最大值的列名( Pandas )

python-3.x - 在 python 中生成签名值

python - Pandas 如何在 agg 函数后展平列?

python - matplotlib 中带有单像素标记的散点图