Can we set another value to take place of missing values instead of None or nan?


#1

Question

In the context of this exercise, can we set another value to take place of missing values instead of None or nan?

Answer

After performing an outer merge, missing values will become filled with None or nan by default, and there is no way to set another value during this step.

After the merge, replacing these is a bit easier. You can utilize the fillna() method, which will replace all missing or nan values with another value you specify.

# Replaces all nan values with 0
df.fillna(0, inplace=True)