5

I have multiple dataframes having different years data.

The data in dataframes are:

>>> its[0].head(5)
            Crocs
date             
2017-01-01     46
2017-01-08     45
2017-01-15     43
2017-01-22     43
2017-01-29     41

>>> its[1].head(5)
            Crocs
date             
2018-01-07     23
2018-01-14     21
2018-01-21     23
2018-01-28     21
2018-02-04     25

>>> its[2].head(5)
            Crocs
date             
2019-01-06     90
2019-01-13     79
2019-01-20     82
2019-01-27     82
2019-02-03     81

I tried to plot all these dataframes in single figure (graph), yeah i accomplished but it was not what i wanted.

I plotted the dataframes using the following code

>>> for p in its:
    plt.plot(p.index,p.values)
>>> plt.show()

and i got the following graph Graph i Got by Combing all dfs

but this is not what i wanted i want the graph to be like this Graph i want

Simply i want graph to ignore years and plot by month and days

1 Answer 1

3

You can try of converting the datetime index to timeseries integers based on month and date and plot

df3 = pd.concat(its,axis=1)
xindex= df3.index.month*30 + df3.index.day
plt.plot(xindex,df3)
plt.show()

If you want to have datetime information than integers you can add xticks to frame

labels = (df3.index.month*30).astype(str)+"-" + df3.index.day.astype(str)
plt.xticks(df3.index.month*30 + df3.index.day, labels)
plt.show()
Sign up to request clarification or add additional context in comments.

3 Comments

Just one more question how can i fix this thing by setting interval betweens the labels of date and time
glad to help @IjazUrRahim, we can try of using pd.to_timedelta to fix the specific time intervals without considering year, check pd.to_timedelta and fix it as index. i will update the code inbetween :-)
@Nagakiran: the label does not properly show. Could you please help with that?

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.