【问题标题】:Getting TypeError while parsing a dataframe into Pandas Profiling library将数据帧解析为 Pandas 分析库时出现 TypeError
【发布时间】:2021-04-07 09:47:55
【问题描述】:

我在对数据使用 pandas-profiling 时遇到 TypeError,如下所示:

汇总数据集:2% 1/59 [00:09>

~\Anaconda3\lib\site-packages\pandas\core\algorithms.py in isin(comps, values)
    441         # If the the values include nan we need to check for nan explicitly
    442         # since np.nan it not equal to np.nan
--> 443         if np.isnan(values).any():
    444             f = lambda c, v: np.logical_or(np.in1d(c, v), np.isnan(c))
    445         else:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

请帮忙。我不知道这是怎么回事。

【问题讨论】:

  • 您找到解决方案了吗?有同样的错误。仅在传递具有丢弃 nan 值的数据帧时才有效,但随后它会丢失很多值。尝试更改所有列的 dtypes,尝试填充 nan 值,尝试用 np.nan 替换 'None'、'Null'、'NaN'、'nan' 值。没有任何帮助。
  • 是的,找到了解决方案。只需转到 algorithm.py 并将 np.isnan 替换为 pd.isna。
  • 谢谢!有效! (对周围的任何人附注:不要将您的文件命名为pandas_profiling.py,因为会引发循环引用错误)

标签: python pandas dataframe data-analysis pandas-profiling


【解决方案1】:

自己解决了。查看 Pandas-Profiling Github 页面:

https://github.com/pandas-profiling/pandas-profiling/issues/752#issuecomment-815462226

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-16
    • 1970-01-01
    相关资源
    最近更新 更多