Skip to content

Commit af815f8

Browse files
committed
Small updates
1 parent 2e30a56 commit af815f8

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

pandas/core/arrays/datetimelike.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def _ndarray_values(self):
427427
return self._data
428428

429429
# ------------------------------------------------------------------
430-
# Formatting
430+
# Rendering Methods
431431

432432
def _format_native_types(self, na_rep=u'NaT', date_format=None):
433433
"""
@@ -615,7 +615,7 @@ def fillna(self, value=None, method=None, limit=None):
615615
return new_values
616616

617617
def astype(self, dtype, copy=True):
618-
# Some notes on cases we don't have to handle:
618+
# Some notes on cases we don't have to handle here in the base class:
619619
# 1. PeriodArray.astype handles period -> period
620620
# 2. DatetimeArray.astype handles conversion between tz.
621621
# 3. DatetimeArray.astype handles datetime -> period
@@ -626,9 +626,9 @@ def astype(self, dtype, copy=True):
626626
return self._box_values(self.asi8)
627627
elif is_string_dtype(dtype) and not is_categorical_dtype(dtype):
628628
return self._format_native_types()
629-
# return Index(self.format(), name=self.name, dtype=object)
630629
elif is_integer_dtype(dtype):
631630
# we deliberately ignore int32 vs. int64 here.
631+
# See https://github.com/pandas-dev/pandas/issues/24381 for more.
632632
values = self.asi8
633633
if copy:
634634
values = values.copy()

pandas/core/arrays/datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ def _validate_fill_value(self, fill_value):
573573
return fill_value
574574

575575
# -----------------------------------------------------------------
576-
# Formatting Methods
576+
# Rendering Methods
577+
577578
def _format_native_types(self, na_rep=u'NaT', date_format=None, **kwargs):
578579
from pandas.io.formats.format import _get_format_datetime64_from_values
579580
format = _get_format_datetime64_from_values(self, date_format)

pandas/core/arrays/timedeltas.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ def _maybe_clear_freq(self):
281281

282282
# ----------------------------------------------------------------
283283
# Array-Like / EA-Interface Methods
284-
def _formatter(self, boxed=False):
285-
from pandas.io.formats.format import _get_format_timedelta64
286-
return _get_format_timedelta64(self, box=True)
287284

288285
def __array__(self, dtype=None):
289286
# TODO(https://github.com/pandas-dev/pandas/pull/23593)
@@ -306,6 +303,16 @@ def _validate_fill_value(self, fill_value):
306303
"Got '{got}'.".format(got=fill_value))
307304
return fill_value
308305

306+
# -----------------------------------------------------------------
307+
# Rendering Methods
308+
309+
def _format_native_types(self):
310+
return self.astype(object)
311+
312+
def _formatter(self, boxed=False):
313+
from pandas.io.formats.format import _get_format_timedelta64
314+
return _get_format_timedelta64(self, box=True)
315+
309316
# ----------------------------------------------------------------
310317
# Arithmetic Methods
311318

@@ -775,9 +782,6 @@ def astype(self, dtype, copy=True):
775782
return self
776783
return super(TimedeltaArrayMixin, self).astype(dtype, copy=copy)
777784

778-
def _format_native_types(self):
779-
return self.astype(object)
780-
781785
days = _field_accessor("days", "days",
782786
"Number of days for each element.")
783787
seconds = _field_accessor("seconds", "seconds",

0 commit comments

Comments
 (0)