import pandas as pd pd.set_option('display.unicode.ambiguous_as_wide', True) pd.set_option('display.unicode.east_asian_width', True) df = pd.read_csv('https://media-zip1.baydn.com/storage_media_zip/srfeae/dc3fa2c70032c4f4dfd7d878d79eb4da.41767dfc9dd1646b2a9f71527db2125f.csv') df['评分'] = df['评分'].str.replace('分','').astype('float') df['评分'].fillna(df['评分'].mean().round(1),inpalce = True) print(df.info()) print('====================================') print(df.describe()) df.to_csv('豆瓣图书Top250修正.csv')代码纠错
时间: 2023-09-26 12:06:48 浏览: 419
pandas.read_csv参数详解(小结)
在代码中,将 `inpalce` 写成了 `inplace`,所以会报错。正确的代码如下:
```
import pandas as pd
pd.set_option('display.unicode.ambiguous_as_wide', True)
pd.set_option('display.unicode.east_asian_width', True)
df = pd.read_csv('https://media-zip1.baydn.com/storage_media_zip/srfeae/dc3fa2c70032c4f4dfd7d878d79eb4da.41767dfc9dd1646b2a9f71527db2125f.csv')
df['评分'] = df['评分'].str.replace('分','').astype('float')
df['评分'].fillna(df['评分'].mean().round(1), inplace=True)
print(df.info())
print('====================================')
print(df.describe())
df.to_csv('豆瓣图书Top250修正.csv')
```
希望能帮到您!
阅读全文