【发布时间】:2021-12-14 15:51:45
【问题描述】:
我正在尝试使用以下方法将我的数据集拆分为训练集和测试集:
for train_set, test_set in stratified.split(complete_df, complete_df["loan_condition_int"]):
stratified_train = complete_df.loc[train_set]
stratified_test = complete_df.loc[test_set]
我的数据框 complete_df 没有任何 NaN 值。我通过使用返回0 的complete_df.isnull().sum().max() 来确保它。
但我仍然收到警告说:
Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.
这会导致稍后出现错误。我尝试使用我在网上找到的一些技术,但仍然无法修复它。
【问题讨论】:
-
train_set或test_set包含不在complete_df索引中的值。
标签: pandas dataframe machine-learning