First and last dates of a time series are as follows:
firstday = transactions["Date"].head(1)
firstday
lastday = transactions["Date"].tail(1)
lastday
Dateindex
2017-12-30 2017-12-30
Name: Date, dtype: datetime64[ns]
Dateindex
2018-12-31 2018-12-31
Name: Date, dtype: datetime64[ns]
I want the following two things:
1) get firstday and lastday as "2017-12-30" and "2018-12-31" (strings), instead of dtype('<M8[ns]')
2) calculate the number of whole months between these dates (correct output would be 12 months)
Any ideas how to achieve these? Thank you.