-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
DOC: update the pd.DataFrame.memory_usage/empty docstring(Seoul) #20102
Conversation
There is a related PR on Series.memory_usage: #20086 |
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 for this PR!
A few comments are below.
Also please change the "default is False" for index in the docstring which is True.
pandas/core/frame.py
Outdated
object 40000 | ||
bool 5000 | ||
dtype: int64 | ||
>>> df.memory_usage(index=False) |
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'm not certain the two latter examples (with index=False
and True) bring anything. Just the first example might be enough.
pandas/core/generic.py
Outdated
@@ -1436,12 +1436,20 @@ def __contains__(self, key): | |||
|
|||
@property | |||
def empty(self): | |||
"""True if NDFrame is entirely empty [no items], meaning any of the | |||
""" | |||
True if DataFrame is empty. |
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.
It should be """True [...]
I think (no empty line)
Edit: nevermind, the official docstring example doesn't seem to do that.
pandas/core/generic.py
Outdated
Returns | ||
------- | ||
empty : boolean | ||
if DataFrame is empty, return true, if not return false. |
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.
True, False
coordinate text with #20086 |
pandas/core/frame.py
Outdated
|
||
Examples | ||
-------- | ||
>>> dtypes = ['int64', 'float64', 'complex128', 'object', 'bool'] |
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.
add a categorical type here as well
pandas/core/frame.py
Outdated
@@ -1969,6 +1973,38 @@ def memory_usage(self, index=True, deep=False): | |||
See Also | |||
-------- | |||
numpy.ndarray.nbytes |
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.
add Series.memory_usage
Series.nbytes
* Consistent with Series.memory_usage * Added Categorical notes [ci skip]
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.
Merging later today.
Codecov Report
@@ Coverage Diff @@
## master #20102 +/- ##
==========================================
- Coverage 91.72% 91.7% -0.03%
==========================================
Files 150 150
Lines 49149 49149
==========================================
- Hits 45083 45071 -12
- Misses 4066 4078 +12
Continue to review full report at Codecov.
|
pandas/core/frame.py
Outdated
The memory usage can optionally include the contribution of | ||
the index and elements of `object` dtype. | ||
|
||
A configuration option, `display.memory_usage` (see Parameters) |
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.
There seems to be missing something in this sentence.
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.
Fixed.
[ci skip]
@ohahohah Thanks for the PR! |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.
Lastly, I left errors already occurred in the previous version without changes.