fill nan with 0 pandas and rest with 1 code example Example: how to fill nan values with mean in pandas df.fillna(df.mean())