使用熊猫如何创建下面提到的数据框
输入文件
01 Jeff Thomoson 000 11-28-2018 Payments 2,400 Wire transfer
01 Jeff Thomoson 000 11-29-2018 Interest 100 account
01 Paul Simson 000 11-12-2018 Payments 1,000 Wire transfer
01 Paul Simson 000 11-18-2018 Payments 140 net banking
01 John Sans 000 11-28-2018 Payments 300 cheque
输出文件
TR USER NAME TR Mode Date Narration Amt Mode
01 Jeff Thomoson 000 11-28-2018 Payments 2,400 Wire transfer
01 Jeff Thomoson 000 11-29-2018 Interest 100 account
01 Paul Simson 000 11-12-2018 Payments 1000 Wire transfer
01 Paul Simson 000 11-18-2018 Payments 140 Net banking
01 John Sans 000 11-28-2018 Payments 300 cheque
答案 0 :(得分:1)
Dyz拥有了。您需要使用config
。对于您的示例数据,这是开箱即用的:
pd.read_fwf
如果仍然存在解析错误,则可能需要稍微调整一下宽度。