我有以下格式的熊猫数据框。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
提交
取消