Skip to content

CLN: remove _to_M8 #30840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ def tz_to_dtype(tz):
return DatetimeTZDtype(tz=tz)


def _to_M8(key, tz=None):
"""
Timestamp-like => dt64
"""
if not isinstance(key, Timestamp):
# this also converts strings
key = Timestamp(key)
if key.tzinfo is not None and tz is not None:
# Don't tz_localize(None) if key is already tz-aware
key = key.tz_convert(tz)
else:
key = key.tz_localize(tz)

return np.int64(conversion.pydt_to_i8(key)).view(_NS_DTYPE)


def _field_accessor(name, field, docstring=None):
def f(self):
values = self.asi8
Expand Down
1 change: 0 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pandas.core.accessor import delegate_names
from pandas.core.arrays.datetimes import (
DatetimeArray,
_to_M8,
tz_to_dtype,
validate_tz_from_dtype,
)
Expand Down
13 changes: 1 addition & 12 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pandas.errors import PerformanceWarning

import pandas._testing as tm
from pandas.core.indexes.datetimes import DatetimeIndex, _to_M8, date_range
from pandas.core.indexes.datetimes import DatetimeIndex, date_range
from pandas.core.series import Series

from pandas.io.pickle import read_pickle
Expand Down Expand Up @@ -81,17 +81,6 @@ class WeekDay:
SUN = 6


####
# Misc function tests
####


def test_to_M8():
valb = datetime(2007, 10, 1)
valu = _to_M8(valb)
assert isinstance(valu, np.datetime64)


#####
# DateOffset Tests
#####
Expand Down