'How to get rid of the error with merging year and month column?

how can I get rid of error with date_one and date_two:

TypeError: 'AxesSubplot' object is not subscriptable

and with date_three I get:

AttributeError: 'AxesSubplot' object has no attribute 'assign'

My code

df = pd.read_csv('co2_mm_mlo.csv', comment='#', sep=',', index_col=False)
print(df, '\n')
df['date_one'] = pd.to_datetime(dict(year=df['year'], month=df['month']), format='%Y%m')
df['date_two'] = pd.to_datetime(df[['year', 'month']].assign(Day=1)).dt.strftime('%Y-%m')
df['date_three'] = pd.to_datetime(df.assign(day=1)[['year','month','day']]).dt.to_period('m')
df = df.set_index('date_one')
print(df, '\n')


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source