扫描异常值时出现无效的比较错误

2024-03-28 10:11:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从熊猫数据帧中提取异常值。我想通过分位数之间的距离来提取它们,但是它触发了“TypeError:Invalid comparison between dtype=float64 and str”,但是我看不出它是字符串还是浮点,当我检查我正在比较的两个东西时,upp\u iqr,low\u iqr where熊猫.core.series系列和价格表1.core.frame框架。数据帧。数据帧的单元格中只有数字。这是我的密码:

    prices_list = df.filter(regex='Price')
    q1 = prices_list.quantile(0.25)
    q3 = prices_list.quantile(0.75)
    iqr = q3 - q1
    low_iqr = q1 - (1.5 * iqr)
    upp_iqr = q3 + (1.5 * iqr)
    if any(x > low_iqr for x in prices_list):
        print("check_outlier: False")
        logging.debug(print(price_outliers))
    else:
        print("check_outlier: False")
        logging.debug(print(price_outliers))

我希望它返回一个带有它们的值和位置的数据帧。如有任何帮助,我们将不胜感激,谢谢


Tags: 数据corefalseloggingchecklistlowprices