I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
import pandas as pd a = pd.Series(1, index=pd.to_datetime(['2000-01-01', '2000-01-03'])) b = pd.Series(2, index=pd.to_datetime(['2000-01-02', '2000-01-04'])) pd.concat([a, b], axis=1)Issue Description
concat
documentation states concat will not sort by default. I believe the default sort behavior was deprecated some time ago. However, there is still a sort=True
behavior for DatetimeIndex
:
0 1
2000-01-01 1.0 NaN
2000-01-02 NaN 2.0
2000-01-03 1.0 NaN
2000-01-04 NaN 2.0
The source of this behavior is a hard-coded special-casing in pandas.core.indexes.api.union_indexes
. Making this not sort by default seems to break at least one test (test_concat_datetime_timezone
) and possibly more.
Per the docs, I would expect no sort by default. But that might surprise users if changed. I suppose this either needs to be documented (if intentional) or deprecated (if not intentional).
Installed Versions.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4