异常发生在PyCharm

Exception occurring just in PyCharm

当我尝试 调试 PyCharm IDE 中的以下代码时,我得到 'NoneType' object is not callable'。 在 Visual Studio 代码中调试时,或者在 运行 中调试代码时,我都没有得到相同的错误 Pycharm.

new_dataframe = dataframe.replace("\"", "", regex = True)

此代码片段也复制了错误:

import pandas

dataframe = pandas.DataFrame()
dataframe['PMES'] = ['No', None]

new_dataframe = dataframe.replace("\"", "", regex = True)

teste = ""

这是我在 Visual Studio 代码

中的 DataFrame(在 DataViewer 中看到的)

DataFrame in Visual Studio Code

这是PyCharm中的DataFrame。

DataFrame in PyCharm

在同一个项目中可视化的两个 DataFrame,具有相同的代码,错误仅发生在 PyCharm。

更新

这是带有审查的完整 PyCharm 追溯。

Traceback (most recent call last):
  File "C:\???\???\???\???\???\???\???\conversion\tabula\__init__.py", line 133, in format_dataframe
    new_dataframe = dataframe.replace("\"", "", regex = True)
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 5238, in replace
    return super().replace(
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py", line 6609, in replace
    new_data = self._mgr.replace(
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\managers.py", line 437, in replace
    return self.apply(
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\managers.py", line 327, in apply
    applied = getattr(b, f)(**kwargs)
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\blocks.py", line 686, in replace
    return self._replace_regex(to_replace, value, inplace=inplace)
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\internals\blocks.py", line 759, in _replace_regex
    replace_regex(new_values, rx, value, mask)
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\array_algos\replace.py", line 152, in replace_regex
    f = np.vectorize(re_replacer, otypes=[np.object_])
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\lib\function_base.py", line 2120, in __init__
    otypes = ''.join([_nx.dtype(x).char for x in otypes])
  File "C:\Users\???\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\lib\function_base.py", line 2120, in <listcomp>
    otypes = ''.join([_nx.dtype(x).char for x in otypes])
TypeError: 'NoneType' object is not callable

这似乎是 known numpy bug #21008 with Python 3.10. There are plenty of complaints about this on the PyCharm boards too. The internal numpy discussion suggests that a fix is expected with numpy 1.22.4。在那之前,Python 3.9.12 似乎没有这个问题。