我想处理这个数据集,但正如您在图像中看到的,我在索引之前看到了一个未命名的行。但是,当我检查第一行以删除它时,我发现它与dataFrame中的索引中的数据有些合并。所以我试着删除第一行,但它仍然与下一行合并,然后我搜索所有行,它在所有行中。对如何摆脱它有什么想法吗?任何帮助都是非常感谢的。代码和输出如下:
数据帧头的片段,包括“未命名”行
df.iloc[0]
2834897563
2906056396
Unnamed: 1
3.7
data analyst intern
model based systems engineering (mbse) and req...
Mid-Atlantic Physician
General Motors
Rockville
Warren
MD
MI
nan
69.0
nan.1
101.0
https://www.glassdoor.com/partner/jobListing.htm? pos=1801&ao=4121&s=58&guid=0000016511cb3879892978f692c8947b&src=GD_JOB_AD&t =SR&extid=1&exst=OL&ist=&ast=OL&vt=w&slr=true&rtp=0&cs=1_5a2aa76f&cb=153360 1855999&jobListingId=2834897563
https://www.glassdoor.com/partner/jobListing.h...
['include', 'analysis.', 'to', 'provide', 'hedis', 'includes',
'review', 'clinical', 'the', 'risk', 'mid', 'information',
'students', 'works', 'our', 'that', 'systems', 'create', 'ncqa',
'process', 'assistant', 'other', 'adjustment', 'data', 'querying',
'interns', 'identified'] ['areapplied', 'teams', 'gmvehicle',
'these', ...
Newark
Detroit
MI
['1', '50']
['10000']
HealthCare
Manufacturing
Name: 0, dtype: object```
[1]: https://i.stack.imgur.com/8SSAH.png发布于 2021-04-16 14:12:36
看起来您有一个不需要的列,这就是为什么您会在所查看的每一行上看到它的值。
要验证这种情况,您可以通过以下方式查看DataFrame的列(第二列应该是您不想要的列):
df.columns如果确实是这样,您可以通过以下方式从整个DF中删除该列:
df.drop(1,axis=1)注意,这将只返回不带列的DF,如果你想在df对象本身中删除,你可以添加inplace=True。
相关文档在这里:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html
https://stackoverflow.com/questions/67118578
复制相似问题