1

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 graph 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?

1 Answer 1

1

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()

enter image description here

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:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

But how can I get 2 curves to Credit and mortgage on the one plot?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.