I would like to understand if I can convert a column with mixed types (DateTime and Strings) to a PeriodIndex (for instance month).
I have the following DataFrame:
booking_date ... credit debit
None ... 10185.00 -10185.00
2017-01-01 00:00:00 ... 1796.00 0.00
2018-07-01 00:00:00 ... 7423.20 -11.54
2017-04-01 00:00:00 ... 1704.00 0.00
2017-12-01 00:00:00 ... 1938.60 -1938.60
2018-12-01 00:00:00 ... 1403.47 -102.01
2018-01-01 00:00:00 ... 2028.00 -76.38
2019-01-01 00:00:00 ... 800.00 -256.98
Total ... 10185.00 -10185.00
I'm trying to apply the PeriodIndex to booking_date:
df['booking_date'] = pd.PeriodIndex(df['booking_date'].values, freq='M')
However, I receive the following error:
pandas._libs.tslibs.parsing.DateParseError: Unknown datetime string format, unable to parse: TOTAL
Anyway I can get around with this?
Thanks!