Answers for "fill column with another column pandas fillna"

3

pandas fill na with value from another column

df['Cat1'].fillna(df['Cat2'])
Posted by: Guest on May-22-2020
10

how to fillna in all columns with their mean values

# if you want to fill NaN in a single column with its mean value
df['col'].fillna(df['col'].mean(), inplace=True)

# if you want to fill NaN in more than one columns with their respective mean values
df.fillna(df.mean(), inplace=True)
Posted by: Guest on October-17-2021

Code answers related to "fill column with another column pandas fillna"

Python Answers by Framework

Browse Popular Code Answers by Language