Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pandas-dev/pandas into di…
Browse files Browse the repository at this point in the history
…v_zero2
  • Loading branch information
jbrockmendel committed Feb 2, 2018
2 parents aa969f8 + 69cd5fb commit 64b0c08
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 325 deletions.
10 changes: 5 additions & 5 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ Other API Changes
- :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`)
- 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`)
- Set operations (union, difference...) on :class:`IntervalIndex` with incompatible index types will now raise a ``TypeError`` rather than a ``ValueError`` (:issue:`19329`)
- :class:`DateOffset` objects render more simply, e.g. "<DateOffset: days=1>" instead of "<DateOffset: kwds={'days': 1}>" (:issue:`19403`)

.. _whatsnew_0230.deprecations:

Expand Down Expand Up @@ -496,6 +497,8 @@ Datetimelike
- Bug in subtracting :class:`Series` from ``NaT`` incorrectly returning ``NaT`` (:issue:`19158`)
- Bug in :func:`Series.truncate` which raises ``TypeError`` with a monotonic ``PeriodIndex`` (:issue:`17717`)
- Bug in :func:`~DataFrame.pct_change` using ``periods`` and ``freq`` returned different length outputs (:issue:`7292`)
- 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`)
-

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

-


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

Plotting
^^^^^^^^

- :func: `DataFrame.plot` now raises a ``ValueError`` when the ``x`` or ``y`` argument is improperly formed (:issue:`18671`)
- Bug in formatting tick labels with ``datetime.time()`` and fractional seconds (:issue:`18478`).
-
- :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).
-

Groupby/Resample/Rolling
Expand All @@ -597,7 +597,7 @@ Sparse
^^^^^^

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

Reshaping
Expand Down
8 changes: 8 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ class _BaseOffset(object):
_normalize_cache = True
_cacheable = False
_day_opt = None
_attributes = frozenset(['n', 'normalize'])

@property
def kwds(self):
# for backwards-compatibility
kwds = {name: getattr(self, name, None) for name in self._attributes
if name not in ['n', 'normalize']}
return {name: kwds[name] for name in kwds if kwds[name] is not None}

def __call__(self, other):
return self.apply(other)
Expand Down
26 changes: 15 additions & 11 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def f(self):
if field in ['is_month_start', 'is_month_end',
'is_quarter_start', 'is_quarter_end',
'is_year_start', 'is_year_end']:
month_kw = (self.freq.kwds.get('startingMonth',
self.freq.kwds.get('month', 12))
if self.freq else 12)
freq = self.freq
month_kw = 12
if freq:
kwds = freq.kwds
month_kw = kwds.get('startingMonth', kwds.get('month', 12))

result = fields.get_start_end_field(values, field,
self.freqstr, month_kw)
Expand Down Expand Up @@ -118,8 +120,16 @@ def wrapper(self, other):
else:
if isinstance(other, list):
other = DatetimeIndex(other)
elif not isinstance(other, (np.ndarray, Index, ABCSeries)):
other = _ensure_datetime64(other)
elif not isinstance(other, (np.datetime64, np.ndarray,
Index, ABCSeries)):
# Following Timestamp convention, __eq__ is all-False
# and __ne__ is all True, others raise TypeError.
if opname == '__eq__':
return np.zeros(shape=self.shape, dtype=bool)
elif opname == '__ne__':
return np.ones(shape=self.shape, dtype=bool)
raise TypeError('%s type object %s' %
(type(other), str(other)))

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


def _ensure_datetime64(other):
if isinstance(other, np.datetime64):
return other
raise TypeError('%s type object %s' % (type(other), str(other)))


_midnight = time(0, 0)


Expand Down
3 changes: 2 additions & 1 deletion pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ def to_native_types(self, slicer=None, na_rep='nan', quoting=None,
**kwargs):
""" convert to our native types format, slicing if desired """

values = self.values
values = self.get_values()

if slicer is not None:
values = values[:, slicer]
mask = isna(values)
Expand Down
Loading

0 comments on commit 64b0c08

Please sign in to comment.