Issue
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.
Solution
How about this:
features = set(data.columns.drop('Price'))
x = new_data.loc[:,features].astype(float)
Answered By - ashkangh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.