Reputation: 4452
I have dataframe
bank_card used_at unique_users all_time
0 Credit 2015-01 513 2368.0
1 Credit 2015-02 352 1375.0
2 mortgage 2015-01 355 1235.0
3 mortgage 2015-02 394 2147.0
4 mortgage 2015-03 298 1401.0
5 mortgage 2015-04 350 1890.0
And I need to build graph. I try to do it and get
But I need to get
used_at
values at x
axis.
all_time
at y
axis to every type of bank_card
.
It establish only name of axis ax.set_xlabel("used_at", fontsize=12)
How can I do that?
Upvotes: 1
Views: 47
Reputation: 169504
You can do this by setting the index to 'used_at'
idf = df.set_index('used_at')
Result:
>>> idf.plot(y='all_time')
<matplotlib.axes._subplots.AxesSubplot object at 0x0000000011D0FDA0>
>>> plt.show()
Edit: you want both Credit and Mortgage on one plot here you go:
>>> idf.groupby('bank_card')['all_time'].plot()
bank_card
Credit Axes(0.125,0.1;0.775x0.8)
mortgage Axes(0.125,0.1;0.775x0.8)
Name: all_time, dtype: object
>>> plt.legend(loc='best')
<matplotlib.legend.Legend object at 0x0000000011924588>
>>> plt.show()
Result:
Upvotes: 1