import pandas as pd
import numpy as np
#Create dataframe with numpy array
df = pd.DataFrame(data=np.random.randint(-100,100,size=[5,5]),
columns=["c1","c2","c3","c4","c5"])
print("Original dataframe")
print(df)
# Generate NaN values
df1 = df[df>0]
print("Dataframe with NaN values")
print(df1)
# How to fill missing values in dataframe
print("Dataframe with missing values replaced by 99")
print(df1.fillna(value="99"))
'''Output
Original dataframe
c1 c2 c3 c4 c5
0 -31 -1 25 -87 -87
1 -58 41 -56 68 59
2 -73 -13 -23 28 2
3 -71 74 15 -43 -32
4 22 -30 -69 50 63
Dataframe with NaN values
c1 c2 c3 c4 c5
0 NaN NaN 25.0 NaN NaN
1 NaN 41.0 NaN 68.0 59.0
2 NaN NaN NaN 28.0 2.0
3 NaN 74.0 15.0 NaN NaN
4 22.0 NaN NaN 50.0 63.0
Dataframe with missing values replaced by 99
c1 c2 c3 c4 c5
0 99 99 25 99 99
1 99 41 99 68 59
2 99 99 99 28 2
3 99 74 15 99 99
4 22 99 99 50 63
'''