Divya pathak
Divya pathak

Reputation: 3

getting keyerror while extracting rows using .loc[]

I am trying to extract rows from dataframe using .loc[] but getting this error:

KeyError: 'Passing list-likes to .loc or [] with any missing labels is no 
longer supported, see https://pandas.pydata.org/pandas- 
docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

my code is:

new_data = pd.get_dummies(data,drop_first=True)
features = list(set(data.columns)-set(['Price']))
x = new_data.loc[:,features].astype(float) 

please give me a simple answer or in a way I can understand since I am new to this.

Upvotes: 0

Views: 123

Answers (1)

ashkangh
ashkangh

Reputation: 1624

How about this:

features = set(data.columns.drop('Price'))
x = new_data.loc[:,features].astype(float) 

Upvotes: 1

Related Questions