Skip to content

Commit

Permalink
Revert "implement TimedeltaArray asm8, to_timedelta64 (pandas-dev#23205
Browse files Browse the repository at this point in the history
…)" (pandas-dev#23290)

This reverts commit 6e50713.
  • Loading branch information
jorisvandenbossche authored Oct 23, 2018
1 parent 8d8955e commit 14f25bb
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 89 deletions.
16 changes: 0 additions & 16 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,22 +707,6 @@ def tz_localize(self, tz, ambiguous='raise', errors='raise'):
# ----------------------------------------------------------------
# Conversion Methods - Vectorized analogues of Timestamp methods

def to_datetime64(self):
"""
Return numpy datetime64[ns] representation of self. For timezone-aware
cases, the returned array represents UTC timestamps.
Returns
-------
ndarray[datetime64[ns]]
"""
return self.asi8.view('M8[ns]')

@property
def asm8(self):
"""Vectorized analogue of Timestamp.asm8"""
return self.to_datetime64()

def to_pydatetime(self):
"""
Return Datetime Array/Index as object ndarray of datetime.datetime
Expand Down
25 changes: 0 additions & 25 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,31 +352,6 @@ def to_pytimedelta(self):
"""
return tslibs.ints_to_pytimedelta(self.asi8)

def to_timedelta64(self):
"""
Return numpy array with timedelta64[ns] dtype
Returns
-------
ndarray[timedelta64[ns]]
Notes
-----
This returns a view on self, not a copy.
See also
--------
Timedelta.to_timedelta64
"""
return self.asi8.view('m8[ns]')

@property
def asm8(self):
"""
Vectorized analogue of Timedelta.asm8
"""
return self.to_timedelta64()

days = _field_accessor("days", "days",
" Number of days for each element. ")
seconds = _field_accessor("seconds", "seconds",
Expand Down
48 changes: 0 additions & 48 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,6 @@ def test_to_period(self, datetime_index, freqstr):
# an EA-specific tm.assert_ function
tm.assert_index_equal(pd.Index(result), pd.Index(expected))

def test_asm8(self, datetime_index):
dti = datetime_index
arr = DatetimeArrayMixin(dti)

expected = np.array([x.asm8 for x in dti], dtype='M8[ns]')

result = dti.asm8
tm.assert_numpy_array_equal(result, expected)

result = arr.asm8
tm.assert_numpy_array_equal(result, expected)

def test_to_datetime64(self, datetime_index):
dti = datetime_index
arr = DatetimeArrayMixin(dti)

expected = np.array([x.asm8 for x in dti], dtype='M8[ns]')

result = dti.to_datetime64()
tm.assert_numpy_array_equal(result, expected)

result = arr.to_datetime64()
tm.assert_numpy_array_equal(result, expected)

@pytest.mark.parametrize('propname', pd.DatetimeIndex._bool_ops)
def test_bool_properties(self, datetime_index, propname):
# in this case _bool_ops is just `is_leap_year`
Expand Down Expand Up @@ -172,30 +148,6 @@ def test_astype_object(self):
assert asobj.dtype == 'O'
assert list(asobj) == list(tdi)

def test_asm8(self):
tdi = pd.TimedeltaIndex(['1 Hour', '3 Hours'])
arr = TimedeltaArrayMixin(tdi)

expected = np.array([3600, 10800], dtype='m8[ns]') * 1e9

result = tdi.asm8
tm.assert_numpy_array_equal(result, expected)

result = arr.asm8
tm.assert_numpy_array_equal(result, expected)

def test_to_timedelta64(self):
tdi = pd.TimedeltaIndex(['1 Hour', '3 Hours'])
arr = TimedeltaArrayMixin(tdi)

expected = np.array([3600, 10800], dtype='m8[ns]') * 1e9

result = tdi.to_timedelta64()
tm.assert_numpy_array_equal(result, expected)

result = arr.to_timedelta64()
tm.assert_numpy_array_equal(result, expected)

def test_to_pytimedelta(self, timedelta_index):
tdi = timedelta_index
arr = TimedeltaArrayMixin(tdi)
Expand Down

0 comments on commit 14f25bb

Please sign in to comment.