How to fill missing values in a dataset with a desired input using pandas?

786    Asked by ranjan_6399 in Data Science , Asked on Jan 15, 2020
Answered by Ranjana Admin

To fill a null values with something else, let us create a dataframe having some null values

import numpy as np

df = pd.DataFrame({'col1':[1,2,3,np.nan],

                   'col2':[np.nan,555,666,444],

                   'col3':['abc','def','ghi','xyz']})

df.head()



Now we will the null values with a string ‘FILL’

df.fillna('FILL')





Your Answer

Interviews

Parent Categories