-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP #37715: Fix mypy errors in accessor.py #50005
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this necessary code-wise? Creating a Series adds unnecessary overhead
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.
Yea that was my first thought too but the other code branch does work with a series. @bang128 can you just run the asv benchmarks for cat and post the results to make sure no regression?
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.
Not sure if we have coverage here, would probably be better to use a specific example with timeit
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.
Since it said that "expression has type "ndarray", variable has type "Series", I just converted the "ndarray" to "Series"
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.
@WillAyd What do you mean with run the asv benchmarks for cat?
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.
@WillAyd I apologize for my late response. It seems that I need conda to run asv benchmark, don't I? But I am facing a problem installing conda: even though I installed miniconda3, it still says that there is no conda in my machine. Actually, this is the first time I run asv benchmark, can you help me, please?
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.
My guess is you installed conda but maybe didn't run
conda init
to have it get activated by default by your shell.You can alternately try changing
asv_bench/asv.conf.json
to set theenvironment_type
tovirtualenv
instead ofconda
if you can't get the conda setup workingThere 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.
@WillAyd Thank you for your recommendation. I ran asv benchmark successfully, and this is the result:
· Creating environments
· Discovering benchmarks
·· Uninstalling from virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter..
·· Installing 6c677bc <Fix-#37715-accessor.py> into virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter...
· Running 2 total benchmarks (2 commits * 1 environments * 1 benchmarks)
[ 0.00%] · For pandas commit bc987e7 (round 1/2):
[ 0.00%] ·· Building for virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter....
[ 0.00%] ·· Benchmarking virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter
[25.00%] ··· Running (strings.Cat.time_cat--).
[25.00%] · For pandas commit 6c677bc <Fix-#37715-accessor.py> (round 1/2):
[25.00%] ·· Building for virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter....
[25.00%] ·· Benchmarking virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter
[50.00%] ··· Running (strings.Cat.time_cat--).
[50.00%] · For pandas commit 6c677bc <Fix-#37715-accessor.py> (round 2/2):
[50.00%] ·· Benchmarking virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter
[75.00%] ··· strings.Cat.time_cat ok
[75.00%] ··· ============ ====== ======== ========= ============
other_cols sep na_rep na_frac
------------ ------ -------- --------- ------------
0 None None 0.0 14.1±2ms
0 None None 0.001 17.3±0.9ms
0 None None 0.15 17.5±0.6ms
0 None - 0.0 14.6±4ms
0 None - 0.001 8.90±0.4ms
0 None - 0.15 13.2±2ms
0 , None 0.0 15.4±0.7ms
0 , None 0.001 15.2±0.9ms
0 , None 0.15 17.7±1ms
0 , - 0.0 15.0±0.6ms
0 , - 0.001 9.58±0.3ms
0 , - 0.15 12.7±0.6ms
3 None None 0.0 44.5±0.8ms
3 None None 0.001 50.2±2ms
3 None None 0.15 55.0±3ms
3 None - 0.0 44.5±0.7ms
3 None - 0.001 47.8±0.7ms
3 None - 0.15 73.3±4ms
3 , None 0.0 70.7±2ms
3 , None 0.001 67.4±3ms
3 , None 0.15 58.7±4ms
3 , - 0.0 65.7±1ms
3 , - 0.001 65.0±2ms
3 , - 0.15 85.4±6ms
============ ====== ======== ========= ============
[75.00%] · For pandas commit bc987e7 (round 2/2):
[75.00%] ·· Building for virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter....
[75.00%] ·· Benchmarking virtualenv-py3.8-Cython0.29.32-jinja2-matplotlib-numba-numexpr-numpy-odfpy-openpyxl-pyarrow-scipy-sqlalchemy-tables-xlrd-xlsxwriter
[100.00%] ··· strings.Cat.time_cat ok
[100.00%] ··· ============ ====== ======== ========= =============
other_cols sep na_rep na_frac
------------ ------ -------- --------- -------------
0 None None 0.0 9.90±2ms
0 None None 0.001 9.58±1ms
0 None None 0.15 12.8±2ms
0 None - 0.0 8.07±0.6ms
0 None - 0.001 10.3±2ms
0 None - 0.15 11.7±0.7ms
0 , None 0.0 8.87±1ms
0 , None 0.001 8.74±0.08ms
0 , None 0.15 10.7±2ms
0 , - 0.0 7.54±0.5ms
0 , - 0.001 8.46±0.5ms
0 , - 0.15 10.7±0.7ms
3 None None 0.0 44.5±1ms
3 None None 0.001 47.2±1ms
3 None None 0.15 52.4±4ms
3 None - 0.0 43.1±3ms
3 None - 0.001 49.1±3ms
3 None - 0.15 71.6±6ms
3 , None 0.0 72.6±10ms
3 , None 0.001 71.7±4ms
3 , None 0.15 62.2±6ms
3 , - 0.0 68.2±1ms
3 , - 0.001 66.7±2ms
3 , - 0.15 81.5±5ms
============ ====== ======== ========= =============
SOME BENCHMARKS HAVE CHANGED SIGNIFICANTLY.
PERFORMANCE DECREASED.
It seems a bad result, does it mean I need to change something?
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.
Awesome thanks for doing that! Yea looks like wrapping this in a Series slows things down - do you see any other way of getting the typing to work without the Series construction?
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.
Let me try some other ways