pandas - 根据索引在两个数据帧上删除行
问题描述
我正在构建这个功能:
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
?
编辑:
解决方案
推荐阅读
- java - 尝试在我的 android 应用程序中显示步骤数
- kubernetes - glusterfs、heketi 和 kubernetes 自动配置问题
- r - 如何将前导零添加到列中的单个数字行?
- javascript - 我可以在 React 中动态创建状态变量吗?
- reactjs - React setState is not a function upon adding JSON?
- java - List.add(list) 和 List.add(stringbuilder.toString) 的区别
- jquery - 如何正确使用 jQuery This?
- service - 具有依赖关系的健康检查和应用程序服务器
- css - 在一个父 div 中等距放置两个 div,其中一个 div 的位置为固定
- visual-studio-code - 我可以在 VSCode 调试任务的启动命令前添加一个令牌(例如“时间”)吗?