如何解决如何删除数据中这些不需要的列
我从 uci ml 存储库下载了数据并将其粘贴到 excel 中,我正在处理该数据,但我不知道我的数据中一些不需要的列来自何处,但在我的 excel 数据表中没有这样的列礼物
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 506 entries,0 to 505
Data columns (total 19 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 CRIM 506 non-null float64
1 ZN 506 non-null float64
2 INDUS 506 non-null float64
3 CHAS 506 non-null int64
4 NOX 506 non-null float64
5 RM 501 non-null float64
6 AGE 506 non-null float64
7 DIS 506 non-null float64
8 RAD 506 non-null int64
9 TAX 506 non-null int64
10 PTRATIO 506 non-null float64
11 B 506 non-null float64
12 LSTAT 506 non-null float64
13 MEDV 506 non-null float64
14 Unnamed: 14 0 non-null float64
15 Unnamed: 15 0 non-null float64
16 Unnamed: 16 0 non-null float64
17 Unnamed: 17 0 non-null float64
18 Unnamed: 18 1 non-null object
dtypes: float64(15),int64(3),object(1)
memory usage: 75.2+ KB
从 14 到 18 的列号是不需要的,我使用了 drop 函数,但什么也没发生。请帮我解决这个问题....
解决方法
del df[df.Column == 'Unnamed']
或:
df.drop([14:])
另一种方式:
df.drop(df.index[[14:]])
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。