I have a pandas DataFrame with index column = date .
Input:
value date 1986-01-31 22.93 1986-02-28 15.46
I want to put the date on the first day of this month
Output:
value date 1986-01-01 22.93 1986-02-01 15.46
What I tried:
df.index.floor('M') ValueError: <MonthEnd> is a non-fixed frequency
This is potentially because df is generated df = df.resample("M").sum() (The result of this code is the input at the beginning of the question)
I also tried df = df.resample("M", convention='start').sum() . However, this does not work.
I know in R, you can just call floor(date, 'M') .
source share