【发布时间】:2021-06-17 16:59:03
【问题描述】:
我正在尝试使用 .loc[] 从数据框中提取行,但出现此错误:
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'
我的代码是:
new_data = pd.get_dummies(data,drop_first=True)
features = list(set(data.columns)-set(['Price']))
x = new_data.loc[:,features].astype(float)
请给我一个简单的答案或以我能理解的方式,因为我是新手。
【问题讨论】:
-
你能添加你的数据框的一部分和你的预期输出吗?