import pandas as pd
df = pd.read_excel('data2.xlsx')
print(df['Posting Date'].head())
df['Posting Date'] = pd.to_datetime(
df['Posting Date'], infer_datetime_format=True)
print(df['Posting Date'].head())
df.to_excel(excel_writer='data2_V1.xlsx')
使用dt.strfdate()
import pandas as pd
df = pd.read_excel('data2.xlsx')
print(df['Posting Date'].head())
df['Posting Date'] = pd.to_datetime(
df['Posting Date'], infer_datetime_format=True)
print(df['Posting Date'].head())
df['Posting Date'] = df['Posting Date'].dt.strftime("%Y-%m-%d")
print(df['Posting Date'].head())
df.to_excel(excel_writer='data2_V3.xlsx')