Home > Blockchain >  recursion depth exeeded when trying to replace nan with mean
recursion depth exeeded when trying to replace nan with mean

Time:08-19

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

im trying to replace nan values with mean but i keep having this error

RecursionError: maximum recursion depth exceeded

i tried setting the recursion limit to a higher number thinking it was because the dataframe has 1308 rows ,using sys but it didn't work.

CodePudding user response:

Please replace mean value as

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