8000 WIP: DatetimeArray+TimedeltaArray by jbrockmendel · Pull Request #23415 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

WIP: DatetimeArray+TimedeltaArray #23415

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

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
…ike_ea
  • Loading branch information
jbrockmendel committed Nov 2, 2018
commit f92843b596f2bec4c9dda00ea872118663be92e0
26 changes: 3 additions & 23 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class DatetimeIndex(DatetimeArray, DatelikeOps, TimelikeOps,
pandas.to_datetime : Convert argument to datetime
"""
_resolution = cache_readonly(DatetimeArray._resolution.fget)
_shallow_copy = Index._shallow_copy

_typ = 'datetimeindex'
_join_precedence = 10
Expand Down Expand Up @@ -332,29 +333,8 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
we require the we have a dtype compat for the values
if we are passed a non-dtype compat, then coerce using the constructor
"""
if isinstance(values, (DatetimeArray, DatetimeIndex)):
# TODO: should we just pin this and skip the rigmarole?
assert tz == values.tz, (tz, values.tz)
assert freq == values.freq, (freq, values.freq)
values = values.asi8

assert not isinstance(values, (DatetimeArray, DatetimeIndex))

if getattr(values, 'dtype', None) is None:
# empty, but with dtype compat
if values is None:
values = np.empty(0, dtype=_NS_DTYPE)
return cls(values, name=name, freq=freq, tz=tz,
dtype=dtype, **kwargs)
values = np.array(values, copy=False)

if not is_datetime64_dtype(values):
values = ensure_int64(values).view(_NS_DTYPE)

values = getattr(values, 'values', values)

assert isinstance(values, np.ndarray), "values is not an np.ndarray"
assert is_datetime64_dtype(values)
# DatetimeArray._simple_new will accept either i8 or M8[ns] dtypes
4956 assert isinstance(values, np.ndarray), type(values)

arr = DatetimeArray(values, freq=freq, tz=tz)
result = object.__new__(cls)
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0