Skip to content

Commit e2b1941

Browse files
committed
updates
1 parent 1635b73 commit e2b1941

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ Datetimelike
11201120
- Bug in rounding methods of :class:`DatetimeIndex` (:meth:`~DatetimeIndex.round`, :meth:`~DatetimeIndex.ceil`, :meth:`~DatetimeIndex.floor`) and :class:`Timestamp` (:meth:`~Timestamp.round`, :meth:`~Timestamp.ceil`, :meth:`~Timestamp.floor`) could give rise to loss of precision (:issue:`22591`)
11211121
- Bug in :func:`to_datetime` with an :class:`Index` argument that would drop the ``name`` from the result (:issue:`21697`)
11221122
- Bug in :class:`PeriodIndex` where adding or subtracting a :class:`timedelta` or :class:`Tick` object produced incorrect results (:issue:`22988`)
1123+
- Bug in the :class:`Series` repr with Period data missing a space before the data (:issue:`23601`)
11231124
- Bug in :func:`date_range` when decrementing a start date to a past end date by a negative frequency (:issue:`23270`)
11241125
- Bug in :meth:`Series.min` which would return ``NaN`` instead of ``NaT`` when called on a series of ``NaT`` (:issue:`23282`)
11251126
- Bug in :func:`DataFrame.combine` with datetimelike values raising a TypeError (:issue:`23079`)

pandas/core/arrays/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def end_time(self):
332332

333333
def _formatter(self, formatter=None):
334334
if formatter:
335-
return str
335+
return formatter.formatter or str
336336
return "'{}'".format
337337

338338
def __setitem__(

pandas/core/arrays/sparse.py

+10
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,16 @@ def __unicode__(self):
16611661
fill=printing.pprint_thing(self.fill_value),
16621662
index=printing.pprint_thing(self.sp_index))
16631663

1664+
def _formatter(self, formatter=None):
1665+
if formatter is None:
1666+
def fmt(x):
1667+
if isna(x) and isinstance(x, float):
1668+
return 'NaN'
1669+
return str(x)
1670+
1671+
return fmt
1672+
return formatter.formatter
1673+
16641674

16651675
SparseArray._add_arithmetic_ops()
16661676
SparseArray._add_comparison_ops()

pandas/tests/series/test_repr.py

+20-20
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ def test_categorical_series_repr_datetime_ordered(self):
364364
def test_categorical_series_repr_period(self):
365365
idx = period_range('2011-01-01 09:00', freq='H', periods=5)
366366
s = Series(Categorical(idx))
367-
exp = """0 2011-01-01 09:00
368-
1 2011-01-01 10:00
369-
2 2011-01-01 11:00
370-
3 2011-01-01 12:00
371-
4 2011-01-01 13:00
367+
exp = """0 2011-01-01 09:00
368+
1 2011-01-01 10:00
369+
2 2011-01-01 11:00
370+
3 2011-01-01 12:00
371+
4 2011-01-01 13:00
372372
dtype: category
373373
Categories (5, period[H]): [2011-01-01 09:00, 2011-01-01 10:00, 2011-01-01 11:00, 2011-01-01 12:00,
374374
2011-01-01 13:00]""" # noqa
@@ -377,11 +377,11 @@ def test_categorical_series_repr_period(self):
377377

378378
idx = period_range('2011-01', freq='M', periods=5)
379379
s = Series(Categorical(idx))
380-
exp = """0 2011-01
381-
1 2011-02
382-
2 2011-03
383-
3 2011-04
384-
4 2011-05
380+
exp = """0 2011-01
381+
1 2011-02
382+
2 2011-03
383+
3 2011-04
384+
4 2011-05
385385
dtype: category
386386
Categories (5, period[M]): [2011-01, 2011-02, 2011-03, 2011-04, 2011-05]"""
387387

@@ -390,11 +390,11 @@ def test_categorical_series_repr_period(self):
390390
def test_categorical_series_repr_period_ordered(self):
391391
idx = period_range('2011-01-01 09:00', freq='H', periods=5)
392392
s = Series(Categorical(idx, ordered=True))
393-
exp = """0 2011-01-01 09:00
394-
1 2011-01-01 10:00
395-
2 2011-01-01 11:00
396-
3 2011-01-01 12:00
397-
4 2011-01-01 13:00
393+
exp = """0 2011-01-01 09:00
394+
1 2011-01-01 10:00
395+
2 2011-01-01 11:00
396+
3 2011-01-01 12:00
397+
4 2011-01-01 13:00
398398
dtype: category
399399
Categories (5, period[H]): [2011-01-01 09:00 < 2011-01-01 10:00 < 2011-01-01 11:00 < 2011-01-01 12:00 <
400400
2011-01-01 13:00]""" # noqa
@@ -403,11 +403,11 @@ def test_categorical_series_repr_period_ordered(self):
403403

404404
idx = period_range('2011-01', freq='M', periods=5)
405405
s = Series(Categorical(idx, ordered=True))
406-
exp = """0 2011-01
407-
1 2011-02
408-
2 2011-03
409-
3 2011-04
410-
4 2011-05
406+
exp = """0 2011-01
407+
1 2011-02
408+
2 2011-03
409+
3 2011-04
410+
4 2011-05
411411
dtype: category
412412
Categories (5, period[M]): [2011-01 < 2011-02 < 2011-03 < 2011-04 < 2011-05]"""
413413

0 commit comments

Comments
 (0)