I have 2 pandas series data for days in a year that I want to graph on the same axis.
series 1:
date value
01-01 15.6
01-02 13.9
01-03 13.3
...
12-28 19.4
12-29 12.8
12-30 11.7
12-31 11.9
series 2:
date value
02-09 8.3
04-17 27.8
05-07 30.6
05-08 33.3
...
12-23 18.3
12-24 17.2
12-25 11.1
one series has observations from every day in a year and the other only has observations from select days in the year.
Currently dates index is just a string, not a datetime value. The year is irrelevant to the data but its fine to set an abitrary one to convert the data if necessary (like 2015).
How would I achieve this? Is there a way to convert both series to datetime somehow?
If you are having issues converting to a Datetime
object then you just need to add an arbitrary year in there.
df['date'] = pd.to_datetime('2018 '+df.date.astype(str) ,format='%Y %m-%d')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.