-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Added examples for union_categoricals #16397
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: Added examples for union_categoricals #16397
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16397 +/- ##
==========================================
- Coverage 90.41% 90.38% -0.03%
==========================================
Files 161 161
Lines 50997 50999 +2
==========================================
- Hits 46107 46097 -10
- Misses 4890 4902 +12
Continue to review full report at Codecov.
|
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.
minor comments
pandas/core/dtypes/concat.py
Outdated
Notes | ||
----- | ||
|
||
To learn more about categories, see 'link |
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 here .....
and the __
(at the end) should be outside the single quote
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.
and the starting quote should also be backtick (`
), not a single quote (like you did for the ending quote)
[b, c, a, b] | ||
Categories (3, object): [a, b, c] | ||
|
||
`union_categoricals` also works with the case of combining two |
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.
@TomAugspurger @jorisvandenbossche do we quote like this in a doc-string?
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 this is OK (I don't think we consistently follow strict guidelines, but the numpydoc docstring explanation says to use single backticks to refer the keyword arguments or functions)
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.
Nice examples!
pandas/core/dtypes/concat.py
Outdated
Notes | ||
----- | ||
|
||
To learn more about categories, see 'link |
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.
and the starting quote should also be backtick (`
), not a single quote (like you did for the ending quote)
pandas/core/dtypes/concat.py
Outdated
Categories (3, object): [b, c, a] | ||
|
||
By default, the resulting categories will be ordered as they appear | ||
in the data. If you want the categories to be lexsorted, use |
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.
"resulting categories will be ordered as they appear in the data" is not fully correct (or at least subjective misinterpretable).
The final categories are not ordered as they appear in the data, but as they appear in the categories
of the data (ant this is not necessarily the same, as upon construction the categories are sorted, not in order of appearance).
Eg.
In [37]: a = pd.Categorical(["c", "b"])
In [38]: b = pd.Categorical(["a", "b"])
In [39]: pd.api.types.union_categoricals([a, b])
Out[39]:
[c, b, a, b]
Categories (3, object): [b, c, a]
of categoricals. The new categories will be the union of the | ||
categories being combined. | ||
|
||
>>> a = pd.Categorical(["b", "c"]) |
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 add a from pandas.api.types import union_categorical
at the beginning?
[b, c, a, b] | ||
Categories (3, object): [a, b, c] | ||
|
||
`union_categoricals` also works with the case of combining two |
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 this is OK (I don't think we consistently follow strict guidelines, but the numpydoc docstring explanation says to use single backticks to refer the keyword arguments or functions)
@GuessWhoSamFoo Thanks! |
git diff upstream/master --name-only -- '*.py' | flake8 --diff
Copied and posted over examples into the doc string; added link.