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: DataFame.pivot throws exception on python 3.10 #46948

Closed
2 of 3 tasks
Xnot opened this issue May 5, 2022 · 3 comments
Closed
2 of 3 tasks

BUG: DataFame.pivot throws exception on python 3.10 #46948

Xnot opened this issue May 5, 2022 · 3 comments
Labels
Bug Duplicate Report Duplicate issue or pull request Python 3.10

Comments

@Xnot
Copy link
Contributor

Xnot commented May 5, 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
import sys

print(sys.version)
print(pd.__version__)
df = pd.DataFrame({"a": range(5), "b": range(5), "c": range(5)})
df2 = df.pivot("a", "b", "c")

>>> 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
>>> 1.4.2
Traceback (most recent call last):
  File "...\.venv\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 Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File ".../pivot_test.py", line 7, in <module>
    df2 = df.pivot("a", "b", "c")
  File "...\.venv\lib\site-packages\pandas\core\frame.py", line 7876, in pivot
    return pivot(self, index=index, columns=columns, values=values)
  File "...\.venv\lib\site-packages\pandas\core\reshape\pivot.py", line 520, in pivot
    return indexed.unstack(columns_listlike)
  File "...\.venv\lib\site-packages\pandas\core\series.py", line 4157, in unstack
    return unstack(self, level, fill_value)
  File "...\.venv\lib\site-packages\pandas\core\reshape\reshape.py", line 491, in unstack
    unstacker = _Unstacker(
  File "...\.venv\lib\site-packages\pandas\core\reshape\reshape.py", line 133, in __init__
    if num_cells > np.iinfo(np.int32).max:
  File "...\.venv\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

Issue Description

Calling DataFrame.pivot throws a TypeError exception. As far as I can tell this happens 100% of the time regardless of the parameters or contents of the DataFrame. The error does not occur on 1.3.5 + python 3.10 or 1.4.2 + python 3.9.

Expected Behavior

The pivoted DataFrame is returned without throwing an exception.

Installed Versions

pd.show_versions is also crashing on 3.10 :^(

@Xnot Xnot added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 5, 2022
@lithomas1
Copy link
Member

I believe this is a duplicate of #41935. Are you running in debug mode?

@Xnot
Copy link
Contributor Author

Xnot commented May 7, 2022

Yes, upon further testing, the error only occurs when running in debug mode.

@lithomas1 lithomas1 added Duplicate Report Duplicate issue or pull request Python 3.10 and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 7, 2022
@lithomas1
Copy link
Member

OK, will close as duplicate of #41935 then. We are currently blocked there until Cython makes a new 0.29.x release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request Python 3.10
Projects
None yet
Development

No branches or pull requests

2 participants