Skip to content

Commit a0d4725

Browse files
authored
BUG: concat(axis=1) ignoring sort parameter for DatetimeIndex (#55085)
BUG: concat ignoring sort parameter for DatetimeIndex
1 parent 20e87cb commit a0d4725

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

doc/source/whatsnew/v2.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ Groupby/resample/rolling
247247

248248
Reshaping
249249
^^^^^^^^^
250+
- Bug in :func:`concat` ignoring ``sort`` parameter when passed :class:`DatetimeIndex` indexes (:issue:`54769`)
250251
- Bug in :func:`merge` returning columns in incorrect order when left and/or right is empty (:issue:`51929`)
251-
-
252252

253253
Sparse
254254
^^^^^^

pandas/core/indexes/api.py

-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ def _find_common_index_dtype(inds):
288288
raise TypeError("Cannot join tz-naive with tz-aware DatetimeIndex")
289289

290290
if len(dtis) == len(indexes):
291-
sort = True
292291
result = indexes[0]
293292

294293
elif len(dtis) > 1:

pandas/tests/reshape/concat/test_datetimes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ def test_concat_datetime_timezone(self):
7777

7878
exp_idx = DatetimeIndex(
7979
[
80-
"2010-12-31 15:00:00+00:00",
81-
"2010-12-31 16:00:00+00:00",
82-
"2010-12-31 17:00:00+00:00",
8380
"2010-12-31 23:00:00+00:00",
8481
"2011-01-01 00:00:00+00:00",
8582
"2011-01-01 01:00:00+00:00",
83+
"2010-12-31 15:00:00+00:00",
84+
"2010-12-31 16:00:00+00:00",
85+
"2010-12-31 17:00:00+00:00",
8686
]
8787
)
8888

8989
expected = DataFrame(
9090
[
91-
[np.nan, 1],
92-
[np.nan, 2],
93-
[np.nan, 3],
9491
[1, np.nan],
9592
[2, np.nan],
9693
[3, np.nan],
94+
[np.nan, 1],
95+
[np.nan, 2],
96+
[np.nan, 3],
9797
],
9898
index=exp_idx,
9999
columns=["a", "b"],

0 commit comments

Comments
 (0)