Skip to content
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: Incorrect Description For pd.concat sort Argument #57753

Closed
1 task done
Wikilicious opened this issue Mar 6, 2024 · 4 comments · Fixed by #57776
Closed
1 task done

DOC: Incorrect Description For pd.concat sort Argument #57753

Wikilicious opened this issue Mar 6, 2024 · 4 comments · Fixed by #57776
Assignees
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@Wikilicious
Copy link
Contributor

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.concat.html#pandas.concat

Documentation problem

The first part of the documentation for the sort argument in pd.concat is confusing and incorrect.

Sort non-concatenation axis if it is not already aligned. 

It wasn't clear to me if the result df would be sorted if the df's being concatenated were already aligned (but not sorted). I had to manually confirm.

I suspect the wording originated from this bug #4588
Which added FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default.

Suggested fix for documentation

Remove the if it is not already aligned part.

@Wikilicious Wikilicious added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 6, 2024
@rhshadrach
Copy link
Member

Related: #57335

@rhshadrach
Copy link
Member

Thanks for the report; confirmed alignment does not impact the result on main. Would you be interesting in submitting a PR to fix the docs @Wikilicious?

index = pd.Index(["a", "c", "b"])
df = pd.DataFrame({"a": [1, 1, 2], "b": [3, 4, 5]}, index=index)
ser = pd.Series([6, 7, 8], index=index)
print(pd.concat([df, ser], axis=1, sort=True))
#    a  b  0
# a  1  3  6
# b  2  5  8
# c  1  4  7

@Wikilicious
Copy link
Contributor Author

Hi @rhshadrach
Yes, I'm interested in submitting a PR with the suggested fix.

@Wikilicious
Copy link
Contributor Author

take

@rhshadrach rhshadrach added Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants