-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: NDFrame describe #36833
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
REF: NDFrame describe #36833
Conversation
|
||
|
||
def describe_ndframe( | ||
*, |
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.
why is the * needed here?
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.
Just to enforce keyword-only arguments, to avoid any confusion with positional arguments.
pandas/io/formats/describe.py
Outdated
is_timedelta64_dtype, | ||
) | ||
|
||
import pandas as pd |
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.
can we avoid importing pd?
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.
I made concrete imports for Series
and concat
. Unfortunately, for Series
I had to use local import right in place, where Series
is needed, because of the issue with circular imports.
Also, I added test for checking that if include is 'all' then setting exclude will raise ValueError. This case was not covered. |
I like the test, otherwise want to encourage you to look at non-refactor PRs. A few ideas of things that would be really helpful that I don't think anyone is actively working on:
Come to think of it, a while back there was a push to refactor some of the tests to method-specific files (tests.frame.methods, tests.series.methods). We got a lot of that done, but there's always more to do there. For that matter, in tests.arithmetic there are a ton of near-duplicate tests that need to be de-duplicated/parametrized (search for TODO comments) |
The reason I refactor is that first I would like to figure out what the code does. It hasn't been long since I first opened pandas source code. I guess that if it is readable it will help the team maintain the code and implement new features. Since you mentioned the possible areas where the contribution is welcome, I will certainly look at that. Thank you! I am also looking forward to other comments regarding the present PR. |
bc76809
to
2866b74
Compare
2866b74
to
a34b7ef
Compare
not averse to simplifying this, but can you instead do a pre-cursor PR which moves code with NO changes. then little by little make changes. otherwise these are very hard to review. closing this PR. pls issue a new one. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Refactor
NDFrame.describe
method.pandas/io/formats/describe.py
NDFrame.describe
to functiondescribe_ndframe
in the new moduleBenefits:
pandas/core/generic.py