【问题标题】:recursion depth exeeded when trying to replace nan with mean尝试用均值替换 nan 时超出递归深度
【发布时间】:2022-08-18 22:17:39
【问题描述】:
import matplotlib.pyplot as plt
import seaborn
import pandas as pd

df=pd.read_csv(\'C:\\\\Users\\\\Fehmi Laourine\\\\Downloads\\\\aa.csv\',encoding=\'ISO-8859-1\')
df[\'age\'].fillna(df[\'age\'].mean,inplace=True)
df

我试图用平均值替换 nan 值,但我一直有这个错误

RecursionError: maximum recursion depth exceeded

我尝试将递归限制设置为更高的数字,认为这是因为数据框有 1308 行,使用 sys 但它不起作用。

    标签: python pandas dataframe


    【解决方案1】:

    请将平均值替换为

    df['age'].fillna(df['age'].mean(),inplace=True)
    

    【讨论】:

      猜你喜欢
      • 2018-06-08
      • 1970-01-01
      • 2013-04-06
      • 2013-12-01
      • 2019-01-01
      • 1970-01-01
      • 2016-12-10
      • 2016-11-10
      相关资源
      最近更新 更多