我的数据框中有两列。日期格式的其中一列。另一列有1&0;和0' s。我想绘制一个显示两列之间关系的图表。这是我的数据的一小部分
-(UIImage*)merge:(UIImage*)img1 img2:(UIImage*)img2{
CGFloat h = img1.size.height;
CGFloat w = img1.size.width + img2.size.width;
CGSize size = CGSizeMake(w, h);
UIGraphicsBeginImageContextWithOptions(size, NO, 1.0);
[img1 drawInRect:CGRectMake(0,0,img1.size.width, img1.size.height)];
[img2 drawInRect:CGRectMake(0,0,img2.size.width, img2.size.height)];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return finalImage;
}
情节应该是1日和1日相对于日期特别是月份部分的分布,以便我可以决定哪个月有更多的1和更多0& #39; S。提前致谢
答案 0 :(得分:2)
答案 1 :(得分:1)
您可以使用Seaborn的联合图
data['month'] = pd.to_datetime(data['Date']).dt.month
sns.jointplot(x='Consumer',y='month',data=data)]
答案 2 :(得分: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()
答案 3 :(得分:0)
这是我的问题的解决方案。
#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)
#plot the graph
b.plot('month', 'Yes')