Skip to content

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

Merged
merged 2 commits into from
May 22, 2017

Conversation

GuessWhoSamFoo
Copy link
Contributor

@GuessWhoSamFoo GuessWhoSamFoo commented May 20, 2017

Copied and posted over examples into the doc string; added link.

@codecov
Copy link

codecov bot commented May 20, 2017

Codecov Report

Merging #16397 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 88.22% <ø> (-0.03%) ⬇️
#single 40.19% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/dtypes/concat.py 98.07% <ø> (ø) ⬆️
pandas/plotting/_converter.py 63.23% <0%> (-1.82%) ⬇️
pandas/plotting/_core.py 81.89% <0%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f55de1...925a1ce. Read the comment docs.

@jreback jreback added Categorical Categorical Data Type Docs labels May 20, 2017
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments

Notes
-----

To learn more about categories, see 'link
Copy link
Contributor

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

Copy link
Member

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
Copy link
Contributor

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?

Copy link
Member

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)

@jreback jreback added this to the 0.21.0 milestone May 20, 2017
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice examples!

Notes
-----

To learn more about categories, see 'link
Copy link
Member

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)

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
Copy link
Member

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"])
Copy link
Member

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
Copy link
Member

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)

@jorisvandenbossche jorisvandenbossche merged commit d071c65 into pandas-dev:master May 22, 2017
@jorisvandenbossche
Copy link
Member

@GuessWhoSamFoo Thanks!

pcluo pushed a commit to pcluo/pandas that referenced this pull request May 22, 2017
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
@GuessWhoSamFoo GuessWhoSamFoo deleted the union_docstring branch September 7, 2017 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: union_categoricals could use some examples in the doc-string
3 participants