You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
Pandas version checks
main
hereLocation 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 inpd.concat
is confusing and incorrect.It wasn't clear to me if the result
df
would be sorted if thedf
'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.The text was updated successfully, but these errors were encountered: