I have a dataframe that contains 3 columns year month and SPEI value
I want to add day column that contains the first day of each month
CodePudding user response:
If need new column with first day
use:
df['day'] = 1
If need datetime with first day:
df['datetime'] = pd.to_datetime(df[['year','month']].assign(day=1))