← 返回题库
初级

Auto数据集缺失值处理

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
import pandas as pd
auto = pd.read_csv('https://liangdaima.com/static/data/statistics/Auto.csv')
print('缺失值数量:')
print(auto.isnull().sum())
auto['horsepower'] = pd.to_numeric(auto['horsepower'], errors='coerce')
auto = auto.dropna()
print('\
处理后数据形状:', auto.shape)

示例

输入
solve()
期望输出
缺失值数量:
mpg             0
cylinders       0
displacement    0
horsepower      0
weight          0
acceleration    0
year            0
origin          0
name            0
dtype: int64
处理后数据形状: (392, 9)
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码