-
-
Notifications
You must be signed in to change notification settings - Fork 141
Fixed TYP of values argument of the pandas.DataFrame.pivot_table #893
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a test for pivot_table()
that resembles the code in the original issue.
…alues argument in pivot_table
Hello @Dr-Irv , I have included the test case. Can you please have a look and check if it is alright. |
tests/test_frame.py
Outdated
) | ||
check( | ||
assert_type( | ||
df.pivot_table(index="col2", columns="col4", values=["col1", "col3"]), pd.DataFrame, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your test is invalid for pandas. Use this:
df.pivot_table(index="col2", columns="col4", values=["col1", "col3"]), pd.DataFrame, | |
df.pivot_table(index="col1", columns="col3", values=["col2", "col4"]), pd.DataFrame, |
Changed per your suggestion. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you are failing because you didn't install the pre-commit hooks. Please follow the instructions here: https://github.com/pandas-dev/pandas-stubs/blob/main/docs/setup.md to set up your environment.
If you then just add one space character to tests/test_frame.py
, and commit, then black
will reformat the code and fix the issue.
Or you can try editing by hand if you look at what black
did at https://github.com/pandas-dev/pandas-stubs/actions/runs/8366596481/job/22907251773?pr=893
But that's rather risky - you're better off setting up the environment and let the tools do the work for you.
Hopefully, no more formatting issue now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Aftabby
This pull request addresses issue #885 by modifying the pivot_table stub definition in frame.pyi to allow lists of strings as the values argument. Previously, the stub definition only supported single strings or None for values.
Changes Introduced:
Updated the values argument type in the pivot_table stub definition to include _Sequence[str]. This allows lists of strings to be used for values.
Test Case:
No test case added as there was already an existing test case in the file test_frame.py on line 922 :
check(
Which already test the addressed issue and updated fix.
[ ] Closes #885