Question
I have this DataFrame and want only the records whose EPS column is not NaN:
STK_ID EPS cash
STK_ID RPT_Date
601166 20111231 601166 NaN NaN
600036 20111231 600036 NaN 12
600016 20111231 600016 4.3 NaN
601009 20111231 601009 NaN NaN
601939 20111231 601939 2.5 NaN
000001 20111231 000001 NaN NaN
...i.e. something like df.drop(....)
to get this resulting dataframe:
STK_ID EPS cash
STK_ID RPT_Date
600016 20111231 600016 4.3 NaN
601939 20111231 601939 2.5 NaN
How do I do that?
Answer
Don't drop, just take the rows where EPS is not NA:
df = df[df['EPS'].notna()]