I am new to pandas, I have this data frame:
df['educ1']
which gives
1 4
2 3
3 3
4 4
5 1
..
28461 3
28462 2
28463 3
28464 2
28465 4
Name: educ1, Length: 28465, dtype: int64
when I try querying with
dt=df[df.educ1 > 1]
It’s working fine returning multiple rows, but when I try
college_grad_mask=(df.educ1 > 1)
df.where(college_grad_mask).dropna().head()
It gives 0 rows, I wonder what is wrong here?
>Solution :
You likely have NaNs in many columns, try to subset:
df.where(college_grad_mask).dropna(subset=['educ1']).head()
Or better:
df[college_grad_mask].head()