gpt4 book ai didi

pandas - 属性错误 : 'float' object has no attribute 'isnumeric'

转载 作者:行者123 更新时间:2023-12-05 06:02:29 27 4
gpt4 key购买 nike

我有一个 pandas df,我想删除 col1 的非数字值。

如果我使用 df[df.col1.apply(lambda x: x.isnumeric())],我会收到以下错误:

AttributeError: 'float' 对象没有属性 'isnumeric'

关于在 pandas 中有效地执行此操作的任何建议?

最佳答案

您可以使用字符串的标准方法 isnumeric 并将其应用于您的 id 列中的每个值:
Remove non-numeric rows in one column with pandas
Python replace non digit character in a dataframe

关于pandas - 属性错误 : 'float' object has no attribute 'isnumeric' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66910315/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com