date format df code example Example: format date field in pandas df['date'] = pd.to_datetime(df["date"].dt.strftime('%Y-%m'))