Python .drop does not give the result I expect

Viewed 155

I have a dataframe called xxx. One column of xxx is Final and xxx looks like this

  FpPropeTypCode DTE_DATE_DEATH             Area         Final  
0             FP            NaN  Ame_MidEast_Lnd           NaN  
1             FP            NaN  Southern_Europe  W.E.M. Lines  
2             FP            NaN              NaN           NaN  
3             ZP            NaN  Ame_MidEast_Lnd           NaN  
4             YY            NaN  Ame_MidEast_Lnd           NaN  

I would like to remove all rows that has NaN for Final, so what I did was

xxx= xxx.drop(pd.isnull(data_file_fp4['Final']))

Unfortunately what I got is

  FpPropeTypCode DTE_DATE_DEATH             Area                         Final  
2             FP            NaN              NaN                           NaN  
3             ZP            NaN  Ame_MidEast_Lnd                           NaN  
4             YY            NaN  Ame_MidEast_Lnd                           NaN  
5             NN            NaN  Ame_MidEast_Lnd  NORTH ARM TRANSPORTATION LTD  
6             CP            NaN  Northern_Europe                     MPC Group 

which is obviously not right...

What I actually need to do is to drop rows based on two conditions: Final being NaN and Area being Ame_MidEast_Lnd. So I can not really use dropna

What was wrong in my current codes just to do the first condition? Thanks in advance.

1 Answers
Related