1
Shop_name         Bikes_available             Shop_location       Average_price_of_bikes   Rating_of_shop

NYC Velo          Ninja,hbx                      Salida                   5685$               4.2               
Bike Gallery      dtr,mtg,Harley Davidson        Portland                 6022$               4.8

This dataset is stored in dataframe named df. I am tying to create new dataframe that contains only those rows whose shop name, bikes_available and shop_location values are not null

xtrain = df[df['Shop_name','Bikes_available','Shop_location']!=NULL]

Its showing keyerror: ('Shop_name','Bikes_available','Shop_location')

1
  • 1
    Check out notna(). Commented Jun 29, 2020 at 12:20

1 Answer 1

9

First, select multiple columns use [[]]. Then, test for non missing values by DataFrame.notna with DataFrame.all:

xtrain = df[df[['Shop_name','Bikes_available','Shop_location']].notna().all(axis=1)]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.