Skip to content

Incorrect docs for merging categoricals #28166

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

Closed
ivirshup opened this issue Aug 27, 2019 · 2 comments · Fixed by #28185
Closed

Incorrect docs for merging categoricals #28166

ivirshup opened this issue Aug 27, 2019 · 2 comments · Fixed by #28185
Labels

Comments

@ivirshup
Copy link
Contributor

The documentation for merging categorical arrays (here) states that calling pd.concat on two data frames with categorical columns will throw an error. This doesn't throw an error, and probably shouldn't following #13767.

Here's the example shown in the docs:

import pandas as pd
cat = pd.Series(["a", "b"], dtype="category")
vals = [1, 2]
df = pd.DataFrame({"cats": cat, "vals": vals})
df_different = df.copy()
df_different["cats"].cat.categories = ["c", "d"]
try:
    pd.concat([df, df_different])
except ValueError as e:
    print("ValueError:", str(e))
@WillAyd WillAyd added the Docs label Aug 27, 2019
@WillAyd
Copy link
Member

WillAyd commented Aug 27, 2019

Cool thanks! Any interest in submitting a PR to improve the docs?

@WillAyd WillAyd added this to the Contributions Welcome milestone Aug 27, 2019
ivirshup added a commit to ivirshup/pandas that referenced this issue Aug 28, 2019
@ivirshup
Copy link
Contributor Author

Sure! I've gone ahead and given that a shot.

ivirshup added a commit to ivirshup/pandas that referenced this issue Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants