【发布时间】:2022-12-01 14:01:23
【问题描述】:
I'm trying to rearrange an object dataframe to be in DDMMYYYY format. The original format was MM/DD/YYYY.
import string
import pandas as pd
csv_file = 'export.csv'
df = pd.read_csv(csv_file, index_col=False)
df["Date1"] = df["Order_Date"].str.split(" ").str.get(0)
df["Date"] = df["Date1"].str.split("/")
zz= df["Date"]
print(zz)
>>>
0 [11, 01, 2022]
1 [11, 01, 2022]
2 [11, 01, 2022]
3 [11, 01, 2022]
4 [11, 01, 2022]
...
2768 [11, 22, 2022]
2769 [11, 22, 2022]
2770 [11, 22, 2022]
2771 [11, 22, 2022]
2772 [11, 22, 2022]
Name: Date, Length: 2773, dtype: object
I want the output to be like this
>>>
0 [01112022]
1 [01112022]
2 [01112022]
3 [01112022]
4 [01112022]
...
【问题讨论】: