【问题标题】:TypeError: unsupported operand type(s) for &: 'float' and 'bool'类型错误:& 不支持的操作数类型:'float' 和 'bool'
【发布时间】:2021-03-03 13:25:55
【问题描述】:
import pandas as pd

df = pd.read_csv('NISPUF17.csv')
cleaned = df[['CBF_01','P_NUMFLU']]
(cleaned[cleaned['CBF_01']==1]) & (cleaned[cleaned['CBF_01']==2])

【问题讨论】:

  • 请分享您的数据框样本以便更好地理解。

标签: pandas


【解决方案1】:
cleaned[(cleaned['CBF_01']==1) & (cleaned['CBF_01']==2)]

这将为您提供“已清理”数据帧中所需的行

【讨论】:

    猜你喜欢
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-03
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多