-1
df_new=df.fillna(0, inplace=True)
print(df_new.head(10))

why does it shows AttributeError: 'NoneType' object has no attribute 'head'

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Zhen
  • 17
  • 2
  • 4
    If you use `inplace` then the operation is performed *in place*, meaning that it will not return anything. – ddejohn Sep 05 '21 at 23:48
  • 2
    Does this answer your question? [Understanding inplace=True](https://stackoverflow.com/questions/43893457/understanding-inplace-true) – Gino Mempin Sep 05 '21 at 23:55

1 Answers1

4

inplace=True makes it directly modify the original dataframe.

So you would either not to that, like:

df_new = df.fillna(0)
print(df_new.head(10))

Or just keep it as df:

df.fillna(0, inplace=True)
print(df.head(10))
U13-Forward
  • 69,221
  • 14
  • 89
  • 114