Python pandas为excel-fi显示额外的未命名列

2024-09-27 00:12:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用pandas库进行一个项目,在这个项目中,我需要读取一个excel文件,其中包含以下列:

'invoiceid', 'locationid', 'timestamp', 'customerid', 'discount', 'tax',
   'total', 'subtotal', 'productid', 'quantity', 'productprice',
   'productdiscount', 'invoice_products_id', 'producttax',
   'invoice_payments_id', 'paymentmethod', 'paymentdetails', 'amount'

但当我使用下面的python代码阅读此文件时:

^{pr2}$

它返回一些行以及6个未命名的列,其值为NAN。我不知道为什么这些列显示在这里?在

Below is the link to a sample file as requested:

https://mega.nz/#!0MlXCBYJ!Oim9RF56h6hUitTwqSG1354dIKLZEgIszzPrVpfHas8

我是熊猫和机器学习领域的新手。在

请帮帮我!在

提前谢谢!在


Tags: 文件项目idpandasdiscountinvoiceexceltimestamp
1条回答
网友
1楼 · 发布于 2024-09-27 00:12:19

正如在评论中讨论的,问题似乎是,last named列后面有额外的数据。这就是为什么要得到Unnamed列。在

如果你想删除这些列,你可以忽略这些列

df_full = df_full[df_full.filter(regex='^(?!Unnamed)').columns]

相关问题 更多 >

    热门问题