Working with missing data in pandas



First we want to create the dictionary. Next we want to convert the dictionary into dataframe by using pd.dataframe in the pandas concepts for that we want to import the pandas. Then we can do the isnull() function it will check the missing data in the dataframe.








Example-1
import pandas as pd
import numpy as np

d = { 'Score_1' : [ 10, 20, 30, np.nan],
'Score_2' : [ 40, 50, np.nan, 60],
'Score_3' : [ np.nan, 70, 80, 90]}

n = pd.DataFrame(d)

print(n)
print(n.isnull())



Output



  Score_1  Score_2  Score_3
0     10.0     40.0      NaN
1     20.0     50.0     70.0
2     30.0      NaN     80.0
3      NaN     60.0     90.0
   Score_1  Score_2  Score_3
0    False    False     True
1    False    False    False
2    False     True    False
3     True    False    False







Example-2
import pandas as pd
import numpy as np

d = { 'Score_1' : [ np.nan, 5, 10, 15],
'Score_2' : [ 20, 25, np.nan, 30],
'Score_3' : [ 35, np.nan, 45, 50]}

n = pd.DataFrame(d)

print(n)
print(n.isnull())



Output



 Score_1  Score_2  Score_3
0      NaN     20.0     35.0
1      5.0     25.0      NaN
2     10.0      NaN     45.0
3     15.0     30.0     50.0
   Score_1  Score_2  Score_3
0     True    False    False
1    False    False     True
2    False     True    False
3    False    False    False