'Exception occurring just in PyCharm

I get 'NoneType' object is not callable' when I try to debug the following code in PyCharm IDE. I don't get the same error when debbuging at Visual Studio Code nor when I run the code without debugging in Pycharm.

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

This code snippet also replicates the error:

import pandas

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

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

teste = ""

This is my DataFrame (saw in DataViewer) in Visual Studio Code

DataFrame in Visual Studio Code

This is the DataFrame in PyCharm.

DataFrame in PyCharm

Both DataFrames where visualized in the same project, with the same code, the error occurs only in PyCharm.

UPDATE

Here's the full PyCharm traceback with censhorship.

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


Solution 1:[1]

This seems to be a 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. Until then, Python 3.9.12 seems to be free of this problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1