Define a DataFrame
data = {'a':[1,2,3,NaN],'b':['l','k','j','k'],'c':['12r','45h','45u','456u']} frame1 = DataFrame(data) print(frame1) print('\n') print(()) print('\n') print(frame1[()])
Output:
When a column is not pinpointed, but there is a null value in the column, dropna() removes the row where the null value is located, whereas notnull() does not
After pinpointing a column, dropna() outputs series, while notnull() outputs DataFrame
print(frame1) print('\n') print(()) print('\n') print(frame1[()])
Output:
Supplementary: Functions
The notnull function of pandas is used to return a collection of non-null values. An example is given below.
1, construct a DataFrame
df = ([['1', 'bee', 'cat'], [None, None, 'fly']])
2, test notnull function
a = (df[0])
Print out a with the following result.
0 True 1 False
3. Fetch the contents of the df through a
b = df[a] print(b)
prove
0 1 2 0 1 bee cat
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more. If there is any mistake or something that has not been fully considered, please do not hesitate to give me advice.