File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ Categorical
4848
4949**Indexing **
5050
51- -
51+ - Bug in :meth: ` Series.truncate ` when trying to truncate a single-element series ( :issue: ` 35544 `)
5252
5353**DataFrame **
5454- Bug in :class: `DataFrame ` constructor failing to raise ``ValueError `` in some cases when data and index have mismatched lengths (:issue: `33437 `)
Original file line number Diff line number Diff line change @@ -9405,7 +9405,7 @@ def truncate(
94059405 if before > after :
94069406 raise ValueError (f"Truncate: { after } must be after { before } " )
94079407
9408- if ax .is_monotonic_decreasing :
9408+ if len ( ax ) > 1 and ax .is_monotonic_decreasing :
94099409 before , after = after , before
94109410
94119411 slicer = [slice (None , None )] * self ._AXIS_LEN
Original file line number Diff line number Diff line change @@ -141,3 +141,14 @@ def test_truncate_multiindex(self):
141141 expected = df .col
142142
143143 tm .assert_series_equal (result , expected )
144+
145+ def test_truncate_one_element_series (self ):
146+ # GH 35544
147+ series = pd .Series ([0.1 ], index = pd .DatetimeIndex (["2020-08-04" ]))
148+ before = pd .Timestamp ("2020-08-02" )
149+ after = pd .Timestamp ("2020-08-04" )
150+
151+ result = series .truncate (before = before , after = after )
152+
153+ # the input Series and the expected Series are the same
154+ tm .assert_series_equal (result , series )
You can’t perform that action at this time.
0 commit comments