-
-
Notifications
You must be signed in to change notification settings - Fork 143
pivot_table does not accept Series.name as index, columns or value #1212
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
Comments
This is a tough call as to how to proceed. There are 2 options:
While it is valid to write something like If we go to option (2), then my concern is that using |
Hi @Dr-Irv , thank you for your reply. Personally I would be happy to go with option 1. Should we wait for others to join the discussion? Furthermore, how should we proceed? As one could see in the linked pandas-dev/pandas#61432, the pandas documentation also needs to be fixed, one way or another. Should we fix the stubs or the documentation first? |
In this case, I'm fine if we change the stubs. I'm not sure there will be agreement on changing the docs to say that a >>> df = pd.DataFrame({"x":[1,2,3], "let":["a", "b", "c"], "val":[10,20,30]}).set_index(["x", "let"])
>>> df
val
x let
1 a 10
2 b 20
3 c 30
>>> dft = df.T
>>> dft
x 1 2 3
let a b c
val 10 20 30
>>> dft.columns[0]
(np.int64(1), 'a')
>>> dft[dft.columns[0]].name
(np.int64(1), 'a') There are other operations that can create a |
* fix: #1212 Index.name currently has no typing #1212 (comment) * fix: #1212 use typing from pandas.core.reshape.pivot * fix(comment): #1216 (comment)
Describe the bug
pivot_table
does not acceptSeries.name
asindex
,columns
orvalue
To Reproduce
Provide a minimal runnable
pandas
example that is not properly checked by the stubs.Indicate which type checker you are using (
mypy
orpyright
).mypy
Show the error message received from that type checker while checking your example.
Please complete the following information:
OS: [e.g. Windows, Linux, MacOS]
Windows
OS Version [e.g. 22]
10
python version
3.13.2
version of type checker
1.15.0
version of installed
pandas-stubs
2.2.3.250308
Additional context
Related to pandas-dev/pandas#61432
The text was updated successfully, but these errors were encountered: