replace null with 0 in pandas code example

Example 1: how to replace nan with 0 in pandas

df['product']=df['product'].fillna(0)
df['context']=df['context'].fillna(0)
df

Example 2: replace nan in pandas

df['DataFrame Column'] = df['DataFrame Column'].fillna(0)

Example 3: replace "-" for nan in dataframe

df.replace(np.nan,0)

Example 4: pandas replace nulls with zeros

df['col1'] = df['col1'].fillna(0)

Example 5: pandas replace zero with blank

# in column_B of dataframe, replace zero with blanks
df['column_B'].replace(['0', '0.0'], '', inplace=True)