首页 > 解决方案 > 根据索引在两个数据帧上删除行

问题描述

我正在构建这个功能:

def filna_intake(df):
    for j in ['bottom 25% bottom 25%', 'top 25% top 25%', 'mid 50% mid 50%', \
         'mid 50% top 25%', 'mid 50% bottom 25%', 'top 25% mid 50%', 'bottom 25% mid 50%', \
         'top 25% bottom 25%', 'bottom 25% top 25%']:
        df.drop(df.loc[df['intake'] == j].index, inplace=True)

return df

如果我打电话,它工作正常filna_intake(predictors)。但我希望它在另一个名为labels. 我怎样才能在这个函数中做到这一点?如何获取索引并告诉我的函数将相应的行放入labels

编辑:

数据的树干

标签: pandasdataframelabel

解决方案


推荐阅读