【发布时间】:2017-12-07 09:29:49
【问题描述】:
我有一个熊猫数据框。我正在制作散点图并尝试根据颜色条对数据进行分类。我这样做是为了每月分类和质量分类,如下面的示例代码所示。
a = np.random.rand(366)
b = np.random.rand(366)*0.4
index = (pd.date_range(pd.to_datetime('01-01-2000'), periods=366))
df = pd.DataFrame({'a':a,'b':b},index = index)
plt.scatter(df['a'],df['b'],c = df.index.month)
plt.colorbar()
还有质量:
plt.scatter(df['a'],df['b'],c = df.index.quarter)
plt.colorbar()
我的问题:有没有办法按半年分类。例如从 1-6 和 7-12 月份开始,也可以按月份:10-3 和 4-9 谢谢您,您的帮助/建议将不胜感激。
【问题讨论】:
标签: python pandas matplotlib datetimeindex