Skip to content

Commit 64b0c08

Browse files
committed
Merge branch 'master' of https://github.com/pandas-dev/pandas into div_zero2
2 parents aa969f8 + 69cd5fb commit 64b0c08

File tree

17 files changed

+493
-325
lines changed

17 files changed

+493
-325
lines changed

doc/source/whatsnew/v0.23.0.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ Other API Changes
385385
- :func:`DatetimeIndex.shift` and :func:`TimedeltaIndex.shift` will now raise ``NullFrequencyError`` (which subclasses ``ValueError``, which was raised in older versions) when the index object frequency is ``None`` (:issue:`19147`)
386386
- Addition and subtraction of ``NaN`` from a :class:`Series` with ``dtype='timedelta64[ns]'`` will raise a ``TypeError` instead of treating the ``NaN`` as ``NaT`` (:issue:`19274`)
387387
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
388+
- :class:`DateOffset` objects render more simply, e.g. "<DateOffset: days=1>" instead of "<DateOffset: kwds={'days': 1}>" (:issue:`19403`)
388389

389390
.. _whatsnew_0230.deprecations:
390391

@@ -496,6 +497,8 @@ Datetimelike
496497
- Bug in subtracting :class:`Series` from ``NaT`` incorrectly returning ``NaT`` (:issue:`19158`)
497498
- Bug in :func:`Series.truncate` which raises ``TypeError`` with a monotonic ``PeriodIndex`` (:issue:`17717`)
498499
- Bug in :func:`~DataFrame.pct_change` using ``periods`` and ``freq`` returned different length outputs (:issue:`7292`)
500+
- Bug in comparison of :class:`DatetimeIndex` against ``None`` or ``datetime.date`` objects raising ``TypeError`` for ``==`` and ``!=`` comparisons instead of all-``False`` and all-``True``, respectively (:issue:`19301`)
501+
-
499502

500503
Timezones
501504
^^^^^^^^^
@@ -527,8 +530,6 @@ Numeric
527530
- Bug in the :class:`DataFrame` constructor in which data containing very large positive or very large negative numbers was causing ``OverflowError`` (:issue:`18584`)
528531
- Bug in :class:`Index` constructor with ``dtype='uint64'`` where int-like floats were not coerced to :class:`UInt64Index` (:issue:`18400`)
529532

530-
-
531-
532533

533534
Indexing
534535
^^^^^^^^
@@ -573,14 +574,13 @@ I/O
573574
- Bug in :func:`DataFrame.to_parquet` where an exception was raised if the write destination is S3 (:issue:`19134`)
574575
- :class:`Interval` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`)
575576
- :class:`Timedelta` now supported in :func:`DataFrame.to_excel` for xls file type (:issue:`19242`, :issue:`9155`)
576-
-
577577

578578
Plotting
579579
^^^^^^^^
580580

581581
- :func: `DataFrame.plot` now raises a ``ValueError`` when the ``x`` or ``y`` argument is improperly formed (:issue:`18671`)
582582
- Bug in formatting tick labels with ``datetime.time()`` and fractional seconds (:issue:`18478`).
583-
-
583+
- :meth:`Series.plot.kde` has exposed the args ``ind`` and ``bw_method`` in the docstring (:issue:`18461`). The argument ``ind`` may now also be an integer (number of sample points).
584584
-
585585

586586
Groupby/Resample/Rolling
@@ -597,7 +597,7 @@ Sparse
597597
^^^^^^
598598

599599
- Bug in which creating a ``SparseDataFrame`` from a dense ``Series`` or an unsupported type raised an uncontrolled exception (:issue:`19374`)
600-
-
600+
- Bug in :class:`SparseDataFrame.to_csv` causing exception (:issue:`19384`)
601601
-
602602

603603
Reshaping

pandas/_libs/tslibs/offsets.pyx

+8
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,14 @@ class _BaseOffset(object):
302302
_normalize_cache = True
303303
_cacheable = False
304304
_day_opt = None
305+
_attributes = frozenset(['n', 'normalize'])
306+
307+
@property
308+
def kwds(self):
309+
# for backwards-compatibility
310+
kwds = {name: getattr(self, name, None) for name in self._attributes
311+
if name not in ['n', 'normalize']}
312+
return {name: kwds[name] for name in kwds if kwds[name] is not None}
305313

306314
def __call__(self, other):
307315
return self.apply(other)

pandas/core/indexes/datetimes.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def f(self):
7171
if field in ['is_month_start', 'is_month_end',
7272
'is_quarter_start', 'is_quarter_end',
7373
'is_year_start', 'is_year_end']:
74-
month_kw = (self.freq.kwds.get('startingMonth',
75-
self.freq.kwds.get('month', 12))
76-
if self.freq else 12)
74+
freq = self.freq
75+
month_kw = 12
76+
if freq:
77+
kwds = freq.kwds
78+
month_kw = kwds.get('startingMonth', kwds.get('month', 12))
7779

7880
result = fields.get_start_end_field(values, field,
7981
self.freqstr, month_kw)
@@ -118,8 +120,16 @@ def wrapper(self, other):
118120
else:
119121
if isinstance(other, list):
120122
other = DatetimeIndex(other)
121-
elif not isinstance(other, (np.ndarray, Index, ABCSeries)):
122-
other = _ensure_datetime64(other)
123+
elif not isinstance(other, (np.datetime64, np.ndarray,
124+
Index, ABCSeries)):
125+
# Following Timestamp convention, __eq__ is all-False
126+
# and __ne__ is all True, others raise TypeError.
127+
if opname == '__eq__':
128+
return np.zeros(shape=self.shape, dtype=bool)
129+
elif opname == '__ne__':
130+
return np.ones(shape=self.shape, dtype=bool)
131+
raise TypeError('%s type object %s' %
132+
(type(other), str(other)))
123133

124134
if is_datetimelike(other):
125135
self._assert_tzawareness_compat(other)
@@ -146,12 +156,6 @@ def wrapper(self, other):
146156
return compat.set_function_name(wrapper, opname, cls)
147157

148158

149-
def _ensure_datetime64(other):
150-
if isinstance(other, np.datetime64):
151-
return other
152-
raise TypeError('%s type object %s' % (type(other), str(other)))
153-
154-
155159
_midnight = time(0, 0)
156160

157161

pandas/core/internals.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,8 @@ def to_native_types(self, slicer=None, na_rep='nan', quoting=None,
709709
**kwargs):
710710
""" convert to our native types format, slicing if desired """
711711

712-
values = self.values
712+
values = self.get_values()
713+
713714
if slicer is not None:
714715
values = values[:, slicer]
715716
mask = isna(values)

0 commit comments

Comments
 (0)