我有以下格式的熊貓數據框。0 06-10-2000 Deposit $40.001 09-12-2002 Withdraw $1000.002 27-06-2001 Deposit $47.003 07-12-2021 Withdraw $100.004 06-10-2022 Deposit $120.005 06-10-2000 Deposit $40.006 09-12-2024 Withdraw $50.00如何將每一行分成 3 列。想要的理想輸出: Date Status Amount0 06-10-2000 Deposit $40.001 09-12-2002 Withdraw $1000.002 27-06-2001 Deposit $47.003 07-12-2021 Withdraw $100.004 06-10-2022 Deposit $120.005 06-10-2000 Deposit $40.006 09-12-2024 Withdraw $50.00
2 回答

拉莫斯之舞
TA貢獻1820條經驗 獲得超10個贊
您可以使用命名組和extract:
df[1].str.extract('(?P<Date>.*) (?P<Status>.*) (?P<Amount>.*)')
輸出:
Date Status Amount
0 06-10-2000 Deposit $40.00
1 09-12-2002 Withdraw $1000.00
2 27-06-2001 Deposit $47.00
3 07-12-2021 Withdraw $100.00
4 06-10-2022 Deposit $120.00
5 06-10-2000 Deposit $40.00
6 09-12-2024 Withdraw $50.00
添加回答
舉報
0/150
提交
取消