-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the dtypes/ftypes docstring (Seoul) #20100
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
pandas/core/generic.py
Outdated
""" | ||
Return the dtypes in this object. | ||
|
||
Notes |
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 think you can remove the "Notes" header, and just make this the extended summary.
pandas/core/generic.py
Outdated
|
||
Notes | ||
----- | ||
It returns a Series with the data type of each column. |
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.
Maybe replace "it" with "This method". And let's say what the values and index is.
This returns a Series with the data type of each column. The result's index is the
original DataFrame's columns.
Let's also replace all instances of "object" with "DataFrame". I'm not sure why this is in generic.py since I think it's specific to 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.
I'm modifying dtype @property
of the NDFrame in generic.py
Is "This property" okay instead of "This method"?
At first, object
was NDFrame
, but found an error.
Private classes (['NDFrame']) should not be mentioned in public docstring.
but it seems to be better that the way you specify with "DataFrame", I will do that.
pandas/core/generic.py
Outdated
|
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame({'f': pd.np.random.rand(3), |
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 you just write out three floating point values? I'd like to avoid random data.
And FYI in general you don't want to use pd.np
. You'll want to import NumPy manually (it's assumed to be imported in our docstrings.)
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.
Ah, and could you just make all these length-1 lists, just to be clearer? so {'f': [1.0], 'i': [1], ...}
pandas/core/generic.py
Outdated
|
||
Notes | ||
----- | ||
Sparse data should have the same dtypes as its dense representation |
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.
End in a .
pandas/core/generic.py
Outdated
2 float64:dense | ||
3 float64:dense | ||
dtype: object | ||
>>> pd.SparseDataFrame(arr).ftypes |
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.
Maybe a blank line before this to break things up a bit.
pandas/core/generic.py
Outdated
|
||
Examples | ||
-------- | ||
>>> arr = pd.np.random.randn(100, 4) |
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.
arr = np.random.RandomState(0).randn(100, 4)
for reproducibility
pandas/core/generic.py
Outdated
"""Return the dtypes in this object.""" | ||
""" | ||
Return the dtypes in this object. | ||
|
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 you please add a Returns section as specified in the guide?
pandas/core/generic.py
Outdated
If object contains data multiple dtypes in a single column, | ||
dtypes will be chosen to accommodate all of the data types. | ||
``object`` is the most general. | ||
|
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 believe in a See Also section ftypes
could be mentioned.
pandas/core/generic.py
Outdated
@@ -4285,6 +4307,31 @@ def ftypes(self): | |||
""" | |||
Return the ftypes (indication of sparse/dense and dtype) |
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.
The docstring guide asks that the summary should fit in a single line. Could you rephrase it that way? If all information could not fit in a single line you can then use an Extended Summary section.
pandas/core/generic.py
Outdated
|
||
See Also | ||
-------- | ||
dtypes, SparseDataFrame |
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.
Instead of simply dtypes
you should use pandas.DataFrame.dtypes
. You can even try linking to dtypes with the notation found in the guide: :meth:`pandas.Series.sum`
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.
Found some points that could be improved. Good sprint for you all!
pandas/core/generic.py
Outdated
|
||
Notes | ||
----- | ||
It returns a Series with the data type of each column. |
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.
Create a 'Returns' section to explain the output. Notes should be used only to explain technical details about the implementation of the algorithm or function behavior.
pandas/core/generic.py
Outdated
@@ -4275,7 +4275,29 @@ def get_ftype_counts(self): | |||
|
|||
@property | |||
def dtypes(self): | |||
"""Return the dtypes in this object.""" | |||
""" | |||
Return the dtypes in this object. |
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.
Explain in more depth to a novice user that this is used to get the dtypes per column of the DataFrame.
pandas/core/generic.py
Outdated
It returns a Series with the data type of each column. | ||
If object contains data multiple dtypes in a single column, | ||
dtypes will be chosen to accommodate all of the data types. | ||
``object`` is the most general. |
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 is worth explaining that str
will be represented as object
.
pandas/core/generic.py
Outdated
"""Return the dtypes in this object.""" | ||
""" | ||
Return the dtypes in this object. | ||
|
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 'See Also' section to contemplate common dtypes.
@@ -4285,6 +4307,31 @@ def ftypes(self): | |||
""" |
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 would better organized it there was pull request for dtypes and another pull request for ftypes.
pandas/core/generic.py
Outdated
@@ -4285,6 +4307,31 @@ def ftypes(self): | |||
""" | |||
Return the ftypes (indication of sparse/dense and dtype) |
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.
Short summary should have 1 line.
pandas/core/generic.py
Outdated
@@ -4285,6 +4307,31 @@ def ftypes(self): | |||
""" | |||
Return the ftypes (indication of sparse/dense and dtype) | |||
in this object. | |||
|
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 return section.
pandas/core/generic.py
Outdated
----- | ||
Sparse data should have the same dtypes as its dense representation | ||
|
||
See Also |
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.
'See Also' should go before notes.
pandas/core/generic.py
Outdated
|
||
See Also | ||
-------- | ||
dtypes, SparseDataFrame |
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.
Make a short description for the itens cited in the summary.
is this overlapping with #20099 ? |
pandas/core/generic.py
Outdated
>>> df = pd.DataFrame({'f': pd.np.random.rand(3), | ||
... 'i': 1, | ||
... 'd': pd.Timestamp('20180310'), | ||
... 'o': 'foo'}) |
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 in See Also to Series.dtype
Hello @lastone9182! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 12, 2018 at 21:10 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #20100 +/- ##
=======================================
Coverage 91.72% 91.72%
=======================================
Files 150 150
Lines 49149 49149
=======================================
Hits 45083 45083
Misses 4066 4066
Continue to review full report at Codecov.
|
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.