I have this Pandas dataframe:
Value
Date
2015-06-01 6.9
2015-07-01 7.5
2015-08-01 7.6
2015-09-01 7.6
2015-10-01 7.9
2015-11-01 7.5
I'm accessing its last index item with this code:
somedate=dict.index[-1]
It is already in a datetime format. When I print somedate I get the following:
2015-11-01 00:00:00
2015-11-01 00:00:00
(not sure why it comes in two lines, but it is working fine anyway)
I'm using this same date to build another dataframe from Pandas:
Prediction MAPE Score
2015-11-01 7.93 1.83 1
Well, all I need is that instead of 2015-11-01 in this last frame, it shows up only as 2015-11.
Can I work this out in the variable somedate or that's something I need to adjust when building the dataframe?
OBS.: I tried to use datetime.strptime, however it seems only to work on string dates, not on timestamps.