Skip to content

ENH: implement DatetimeLikeArray #19902

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 37 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
df9f894
implement DatetimeLikeArray
jbrockmendel Feb 26, 2018
004f137
docstring
jbrockmendel Feb 26, 2018
db72494
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Feb 27, 2018
80b525e
move classes to array directory
jbrockmendel Feb 27, 2018
54009d4
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Feb 27, 2018
65dc829
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Feb 27, 2018
4c5a05c
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Feb 28, 2018
b91ddac
flake8 fixup remove unused import
jbrockmendel Mar 1, 2018
080e477
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Mar 2, 2018
e19f70a
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Mar 7, 2018
47d365e
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Mar 18, 2018
3a67bce
comments for cache_readonlys, append Mixin to name, add imports to __…
jbrockmendel Mar 18, 2018
7fc73eb
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Apr 6, 2018
9edd9bc
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Apr 11, 2018
1236273
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Apr 24, 2018
1ab6263
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Apr 26, 2018
9a28188
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel May 16, 2018
6b17031
fix merge screwup
jbrockmendel May 17, 2018
b03689a
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel May 25, 2018
a055d40
rename arrays to FooArray Mixin
jbrockmendel May 25, 2018
d1faeb6
fixups imports
jbrockmendel May 25, 2018
fcb8d6a
fixup namerror
jbrockmendel May 25, 2018
8cee92c
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel May 26, 2018
375329e
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 4, 2018
71dfe08
fixup missing import
jbrockmendel Jun 4, 2018
59c60a2
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 7, 2018
9db2b78
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 10, 2018
308c25b
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 11, 2018
94bdfcb
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 20, 2018
d589e2a
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 22, 2018
0d4f48a
reorder imports
jbrockmendel Jun 22, 2018
1b910c7
De-pluralize
jbrockmendel Jun 22, 2018
cece116
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 28, 2018
828022a
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 29, 2018
ed83046
fixup remove unused import
jbrockmendel Jun 29, 2018
c1934db
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jun 29, 2018
a684c2d
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
jbrockmendel Jul 2, 2018
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
Prev Previous commit
Next Next commit
Merge branch 'master' of https://github.com/pandas-dev/pandas into dt…
…arrays3
  • Loading branch information
jbrockmendel committed Feb 27, 2018
commit 54009d41234737c0e22c13d1fee3f9ca829871f5
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def _sub_datelike_dti(self, other):
if self.hasnans or other.hasnans:
mask = (self._isnan) | (other._isnan)
new_values[mask] = iNaT
return new_values.view('i8')
return new_values.view('timedelta64[ns]')
22 changes: 22 additions & 0 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,28 @@ def _convert_scalar_indexer(self, key, kind=None):
return (super(DatetimeIndexOpsMixin, self)
._convert_scalar_indexer(key, kind=kind))

def _add_nat(self):
"""Add pd.NaT to self"""
if is_period_dtype(self):
raise TypeError('Cannot add {cls} and {typ}'
.format(cls=type(self).__name__,
typ=type(NaT).__name__))

# GH#19124 pd.NaT is treated like a timedelta for both timedelta
# and datetime dtypes
return self._nat_new(box=True)

def _sub_nat(self):
"""Subtract pd.NaT from self"""
# GH#19124 Timedelta - datetime is not in general well-defined.
# We make an exception for pd.NaT, which in this case quacks
# like a timedelta.
# For datetime64 dtypes by convention we treat NaT as a datetime, so
# this subtraction returns a timedelta64 dtype.
# For period dtype, timedelta64 is a close-enough return dtype.
result = self._nat_new(box=False)
return result.view('timedelta64[ns]')

def _addsub_offset_array(self, other, op):
"""
Add or subtract array-like of DateOffset objects
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import pandas.tseries.frequencies as frequencies
from pandas.tseries.frequencies import get_freq_code as _gfc
from pandas.core.indexes.datetimes import DatetimeIndex, Int64Index, Index
from pandas.core.indexes.timedeltas import TimedeltaIndex
from pandas.core.indexes.datetimelike import (
DatelikeOps, DatetimeIndexOpsMixin)
from pandas.core.indexes.datetimelike import DatelikeOps, DatetimeIndexOpsMixin
from pandas.core.tools.datetimes import parse_time_string
import pandas.tseries.offsets as offsets

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.