Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: unstack/pivot (and other functions) raise TypeError when in debug mode #47069

Closed
3 tasks done
djmcnay opened this issue May 20, 2022 · 1 comment
Closed
3 tasks done
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member Python 3.10

Comments

@djmcnay
Copy link

djmcnay commented May 20, 2022

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

# when run in debug mode
data = dict(x=[1, 2, 3], y=[np.nan, 2, 4], z=[5.345, np.nan, 9.0])
df = pd.DataFrame(data).stack()
df = df.unstack()

Issue Description

When de-bugging python 3.10+ (tested on 3.10.4) several functions, including unstack and pivot will raise TypeError 'NoneType'. Problem only exists in debug mode and code works fine when in production or run as a script.

Search the forums seems this may be to do with the way Numpy is interacting with Cython; tested using Numpy 1.22.3 and Cython 0.29.29 and 0.29.30.

Full traceback:

Traceback (most recent call last):
File "C:\Users\XXX.conda\envs\py10\lib\site-packages\numpy\core\getlimits.py", line 649, in init
self.dtype = numeric.dtype(int_type)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2022.1.1\plugins\python\helpers\pydev\pydevd.py", line 1491, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2022.1.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/XXX/Documents/GitHub/XXX/playground.py", line 9, in
df = df.unstack()
File "C:\Users\XXX.conda\envs\py10\lib\site-packages\pandas\core\series.py", line 4157, in unstack
return unstack(self, level, fill_value)
File "C:\Users\XXX.conda\envs\py10\lib\site-packages\pandas\core\reshape\reshape.py", line 491, in unstack
unstacker = _Unstacker(
File "C:\Users\XXX.conda\envs\py10\lib\site-packages\pandas\core\reshape\reshape.py", line 133, in init
if num_cells > np.iinfo(np.int32).max:
File "C:\Users\XXX.conda\envs\py10\lib\site-packages\numpy\core\getlimits.py", line 651, in init
self.dtype = numeric.dtype(type(int_type))
TypeError: 'NoneType' object is not callable
python-BaseException

Expected Behavior

Should simply unstack dataframe

Installed Versions

pd.show_versions() just throws
AssertionError: C:\Users\T333208.conda\envs\py10\lib\distutils\core.py

when running python 3.10.4, pandas 1.4.2

@djmcnay djmcnay added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 20, 2022
@mroeschke
Copy link
Member

Thanks for the report. The core issue is being tracked in #41935 so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member Python 3.10
Projects
None yet
Development

No branches or pull requests

3 participants