Python 3.x 使用matplotlib或seaborn打印两列之间的关系

Python 3.x 使用matplotlib或seaborn打印两列之间的关系,python-3.x,pandas,matplotlib,seaborn,Python 3.x,Pandas,Matplotlib,Seaborn,我的数据框中有两列。日期格式的列之一。另一列有1和0。我想画一个图表,显示两列之间的关系 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。我想画一个图表,显示两列之间的关系

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。提前谢谢你

关于

import matplotlib.pyplot as plt
% matplotlib inline
df['Date'] = pd.to_datetime(df['Date'])
x = df['Date'].values
y = df['received'].values
plt.scatter(x,y)
plt.show()
我会用条形图

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

您可能会使用Seaborn的jointplot

data['month'] = pd.to_datetime(data['Date']).dt.month
sns.jointplot(x='Consumer',y='month',data=data)]

这里有一个解决我问题的方法

#extract the month form the date

train_data['month'] = pd.to_datetime(train_data['Date received']).dt.month

#crosstab displays the frequency distribution of the variable
#(here "Consumer  disputed?") in a matrix format` 
b = pd.crosstab(train_data['month'], train_data['Consumer disputed?'])


#transform the label month into a column
b.reset_index(level='month', inplace=True)


如果没有显示月份,是否意味着该值为0?否,则该月份将显示在每一行中。假设1和0是随机分布的。。有些月多1,有些月少1。使用该图,我需要确定一年中哪个部分有更多的消费者纠纷(在消费者纠纷栏中,1代表是,0代表否),它不起作用。显示错误“ValueError:第一个参数必须是序列”您可以检查列的数据类型并确保它是int64吗?
#plot the graph
b.plot('month', 'Yes')