automobile数据集里元素不是数字的列有哪些
时间: 2024-06-10 16:06:36 浏览: 41
可以使用以下代码来查看automobile数据集中不是数字的列:
```
import pandas as pd
# 读取automobile数据集
df = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/autos/imports-85.data',header=None)
# 设置列名
df.columns = ['symboling', 'normalized-losses', 'make', 'fuel-type', 'aspiration', 'num-of-doors', 'body-style', 'drive-wheels', 'engine-location', 'wheel-base', 'length', 'width', 'height', 'curb-weight', 'engine-type', 'num-of-cylinders', 'engine-size', 'fuel-system', 'bore', 'stroke', 'compression-ratio', 'horsepower', 'peak-rpm', 'city-mpg', 'highway-mpg', 'price']
# 查看不是数字的列
for column in df.columns:
if not pd.api.types.is_numeric_dtype(df[column]):
print(column)
```
运行上述代码后会输出不是数字的列:make、fuel-type、aspiration、num-of-doors、body-style、drive-wheels、engine-location、engine-type、fuel-system
阅读全文