Skip to content

Commit f440c63

Browse files
authored
Merge branch 'master' into feature/flake8-rst
2 parents 67cf043 + de39bfc commit f440c63

File tree

314 files changed

+3044
-3206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+3044
-3206
lines changed

ci/azure-36-locale_slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- nomkl
1515
- numexpr
1616
- numpy
17-
- openpyxl=2.5.5
17+
- openpyxl
1818
- psycopg2
1919
- pymysql
2020
- pytables

ci/azure-37-locale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- nomkl
1414
- numexpr
1515
- numpy
16-
- openpyxl=2.5.5
16+
- openpyxl
1717
- psycopg2
1818
- pymysql
1919
- pytables

ci/azure-macos-35.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- nomkl
1313
- numexpr
1414
- numpy=1.12.0
15-
- openpyxl=2.5.5
15+
- openpyxl
1616
- pytables
1717
- python=3.5*
1818
- pytz

ci/azure-windows-27.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- matplotlib=2.0.1
1414
- numexpr
1515
- numpy=1.12*
16-
- openpyxl=2.5.5
16+
- openpyxl
1717
- pytables
1818
- python=2.7.*
1919
- pytz

ci/azure-windows-36.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- matplotlib
1212
- numexpr
1313
- numpy=1.14*
14-
- openpyxl=2.5.5
14+
- openpyxl
1515
- parquet-cpp
1616
- pyarrow
1717
- pytables

ci/circle-36-locale.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- nomkl
1414
- numexpr
1515
- numpy
16-
- openpyxl=2.5.5
16+
- openpyxl
1717
- psycopg2
1818
- pymysql
1919
- pytables

ci/requirements-optional-conda.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lxml
1212
matplotlib>=2.0.0
1313
nbsphinx
1414
numexpr>=2.6.1
15-
openpyxl=2.5.5
15+
openpyxl
1616
pyarrow
1717
pymysql
1818
pytables>=3.4.2

ci/requirements-optional-pip.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ lxml
1414
matplotlib>=2.0.0
1515
nbsphinx
1616
numexpr>=2.6.1
17-
openpyxl==2.5.5
17+
openpyxl
1818
pyarrow
1919
pymysql
2020
tables

ci/travis-27.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
- s3fs
3636
- scipy
3737
- sqlalchemy=0.9.6
38-
- xarray=0.8.0
38+
- xarray=0.9.6
3939
- xlrd=0.9.2
4040
- xlsxwriter=0.5.2
4141
- xlwt=0.7.5

ci/travis-36-doc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
- notebook
2323
- numexpr
2424
- numpy=1.13*
25-
- openpyxl=2.5.5
25+
- openpyxl
2626
- pandoc
2727
- pyqt
2828
- pytables

ci/travis-36-slow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- matplotlib
1111
- numexpr
1212
- numpy
13-
- openpyxl=2.5.5
13+
- openpyxl
1414
- patsy
1515
- psycopg2
1616
- pymysql

ci/travis-36.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
- nomkl
2323
- numexpr
2424
- numpy
25-
- openpyxl=2.5.5
25+
- openpyxl
2626
- psycopg2
2727
- pyarrow
2828
- pymysql

doc/source/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ Reshaping, sorting
515515
Series.repeat
516516
Series.squeeze
517517
Series.view
518-
Series.sortlevel
519518

520519

521520
Combining / joining / merging

doc/source/whatsnew/v0.24.0.txt

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,29 @@ array, but rather an ``ExtensionArray``:
180180
This is the same behavior as ``Series.values`` for categorical data. See
181181
:ref:`whatsnew_0240.api_breaking.interval_values` for more.
182182

183+
.. _whatsnew_0240.enhancements.rename_axis:
184+
185+
Renaming names in a MultiIndex
186+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187+
188+
:func:`DataFrame.rename_axis` now supports ``index`` and ``columns`` arguments
189+
and :func:`Series.rename_axis` supports ``index`` argument (:issue:`19978`)
190+
191+
This change allows a dictionary to be passed so that some of the names
192+
of a ``MultiIndex`` can be changed.
193+
194+
Example:
195+
196+
.. ipython:: python
197+
198+
mi = pd.MultiIndex.from_product([list('AB'), list('CD'), list('EF')],
199+
names=['AB', 'CD', 'EF'])
200+
df = pd.DataFrame([i for i in range(len(mi))], index=mi, columns=['N'])
201+
df
202+
df.rename_axis(index={'CD': 'New'})
203+
204+
See the :ref:`advanced docs on renaming<advanced.index_names>` for more details.
205+
183206
.. _whatsnew_0240.enhancements.other:
184207

185208
Other Enhancements
@@ -201,7 +224,6 @@ Other Enhancements
201224
- :func:`~DataFrame.to_csv`, :func:`~Series.to_csv`, :func:`~DataFrame.to_json`, and :func:`~Series.to_json` now support ``compression='infer'`` to infer compression based on filename extension (:issue:`15008`).
202225
The default compression for ``to_csv``, ``to_json``, and ``to_pickle`` methods has been updated to ``'infer'`` (:issue:`22004`).
203226
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`)
204-
- Comparing :class:`Timedelta` with unknown types now return ``NotImplemented`` instead of ``False`` (:issue:`20829`)
205227
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
206228
- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`)
207229
- :meth:`round`, :meth:`ceil`, and meth:`floor` for :class:`DatetimeIndex` and :class:`Timestamp` now support an ``ambiguous`` argument for handling datetimes that are rounded to ambiguous times (:issue:`18946`)
@@ -910,6 +932,8 @@ Other API Changes
910932
has an improved ``KeyError`` message, and will not fail on duplicate column names with ``drop=True``. (:issue:`22484`)
911933
- Slicing a single row of a DataFrame with multiple ExtensionArrays of the same type now preserves the dtype, rather than coercing to object (:issue:`22784`)
912934
- :class:`DateOffset` attribute `_cacheable` and method `_should_cache` have been removed (:issue:`23118`)
935+
- Comparing :class:`Timedelta` to be less or greater than unknown types now raises a ``TypeError`` instead of returning ``False`` (:issue:`20829`)
936+
- :meth:`Index.hasnans` and :meth:`Series.hasnans` now always return a python boolean. Previously, a python or a numpy boolean could be returned, depending on circumstances (:issue:`23294`).
913937

914938
.. _whatsnew_0240.deprecations:
915939

@@ -929,6 +953,7 @@ Deprecations
929953
- :func:`DatetimeIndex.shift` and :func:`PeriodIndex.shift` now accept ``periods`` argument instead of ``n`` for consistency with :func:`Index.shift` and :func:`Series.shift`. Using ``n`` throws a deprecation warning (:issue:`22458`, :issue:`22912`)
930954
- The ``fastpath`` keyword of the different Index constructors is deprecated (:issue:`23110`).
931955
- :meth:`Timestamp.tz_localize`, :meth:`DatetimeIndex.tz_localize`, and :meth:`Series.tz_localize` have deprecated the ``errors`` argument in favor of the ``nonexistent`` argument (:issue:`8917`)
956+
- The class ``FrozenNDArray`` has been deprecated. When unpickling, ``FrozenNDArray`` will be unpickled to ``np.ndarray`` once this class is removed (:issue:`9031`)
932957

933958
.. _whatsnew_0240.prior_deprecations:
934959

@@ -941,13 +966,22 @@ Removal of prior version deprecations/changes
941966
- Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`)
942967
- Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`)
943968
- :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`)
969+
- The ``Series`` constructor and ``.astype`` method will now raise a ``ValueError`` if timestamp dtypes are passed in without a unit (e.g. ``np.datetime64``) for the ``dtype`` parameter (:issue:`15987`)
944970
- Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`)
971+
- The modules ``pandas.types``, ``pandas.computation``, and ``pandas.util.decorators`` have been removed (:issue:`16157`, :issue:`16250`)
945972
- Removed the ``pandas.formats.style`` shim for :class:`pandas.io.formats.style.Styler` (:issue:`16059`)
973+
- :func:`pandas.pnow`, :func:`pandas.match`, :func:`pandas.groupby`, :func:`pd.get_store`, ``pd.Expr``, and ``pd.Term`` have been removed (:issue:`15538`, :issue:`15940`)
946974
- :meth:`Categorical.searchsorted` and :meth:`Series.searchsorted` have renamed the ``v`` argument to ``value`` (:issue:`14645`)
975+
- ``pandas.parser``, ``pandas.lib``, and ``pandas.tslib`` have been removed (:issue:`15537`)
947976
- :meth:`TimedeltaIndex.searchsorted`, :meth:`DatetimeIndex.searchsorted`, and :meth:`PeriodIndex.searchsorted` have renamed the ``key`` argument to ``value`` (:issue:`14645`)
977+
- :meth:`DataFrame.consolidate` and :meth:`Series.consolidate` have been removed (:issue:`15501`)
948978
- Removal of the previously deprecated module ``pandas.json`` (:issue:`19944`)
979+
- The module ``pandas.tools`` has been removed (:issue:`15358`, :issue:`16005`)
949980
- :meth:`SparseArray.get_values` and :meth:`SparseArray.to_dense` have dropped the ``fill`` parameter (:issue:`14686`)
981+
- :meth:`DataFrame.sortlevel` and :meth:`Series.sortlevel` have been removed (:issue:`15099`)
950982
- :meth:`SparseSeries.to_dense` has dropped the ``sparse_only`` parameter (:issue:`14686`)
983+
- :meth:`DataFrame.astype` and :meth:`Series.astype` have renamed the ``raise_on_error`` argument to ``errors`` (:issue:`14967`)
984+
- ``is_sequence``, ``is_any_int_dtype``, and ``is_floating_dtype`` have been removed from ``pandas.api.types`` (:issue:`16163`, :issue:`16189`)
951985

952986
.. _whatsnew_0240.performance:
953987

@@ -1020,7 +1054,10 @@ Datetimelike
10201054
- Bug in :func:`to_datetime` with an :class:`Index` argument that would drop the ``name`` from the result (:issue:`21697`)
10211055
- Bug in :class:`PeriodIndex` where adding or subtracting a :class:`timedelta` or :class:`Tick` object produced incorrect results (:issue:`22988`)
10221056
- Bug in :func:`date_range` when decrementing a start date to a past end date by a negative frequency (:issue:`23270`)
1057+
- Bug in :meth:`Series.min` which would return ``NaN`` instead of ``NaT`` when called on a series of ``NaT`` (:issue:`23282`)
10231058
- Bug in :func:`DataFrame.combine` with datetimelike values raising a TypeError (:issue:`23079`)
1059+
- Bug in :func:`date_range` with frequency of ``Day`` or higher where dates sufficiently far in the future could wrap around to the past instead of raising ``OutOfBoundsDatetime`` (:issue:`14187`)
1060+
- Bug in :class:`PeriodIndex` with attribute ``freq.n`` greater than 1 where adding a :class:`DateOffset` object would return incorrect results (:issue:`23215`)
10241061

10251062
Timedelta
10261063
^^^^^^^^^
@@ -1032,7 +1069,8 @@ Timedelta
10321069
- Bug in :class:`TimedeltaIndex` incorrectly allowing indexing with ``Timestamp`` object (:issue:`20464`)
10331070
- Fixed bug where subtracting :class:`Timedelta` from an object-dtyped array would raise ``TypeError`` (:issue:`21980`)
10341071
- Fixed bug in adding a :class:`DataFrame` with all-`timedelta64[ns]` dtypes to a :class:`DataFrame` with all-integer dtypes returning incorrect results instead of raising ``TypeError`` (:issue:`22696`)
1035-
1072+
- Bug in :class:`TimedeltaIndex` where adding a timezone-aware datetime scalar incorrectly returned a timezone-naive :class:`DatetimeIndex` (:issue:`23215`)
1073+
- Bug in :class:`TimedeltaIndex` where adding ``np.timedelta64('NaT')`` incorrectly returned an all-`NaT` :class:`DatetimeIndex` instead of an all-`NaT` :class:`TimedeltaIndex` (:issue:`23215`)
10361074

10371075
Timezones
10381076
^^^^^^^^^
@@ -1062,7 +1100,7 @@ Offsets
10621100

10631101
- Bug in :class:`FY5253` where date offsets could incorrectly raise an ``AssertionError`` in arithmetic operatons (:issue:`14774`)
10641102
- Bug in :class:`DateOffset` where keyword arguments ``week`` and ``milliseconds`` were accepted and ignored. Passing these will now raise ``ValueError`` (:issue:`19398`)
1065-
-
1103+
- Bug in adding :class:`DateOffset` with :class:`DataFrame` or :class:`PeriodIndex` incorrectly raising ``TypeError`` (:issue:`23215`)
10661104

10671105
Numeric
10681106
^^^^^^^
@@ -1079,6 +1117,7 @@ Numeric
10791117
- Bug in :meth:`DataFrame.astype` to extension dtype may raise ``AttributeError`` (:issue:`22578`)
10801118
- Bug in :class:`DataFrame` with ``timedelta64[ns]`` dtype arithmetic operations with ``ndarray`` with integer dtype incorrectly treating the narray as ``timedelta64[ns]`` dtype (:issue:`23114`)
10811119
- Bug in :meth:`Series.rpow` with object dtype ``NaN`` for ``1 ** NA`` instead of ``1`` (:issue:`22922`).
1120+
- :meth:`Series.agg` can now handle numpy NaN-aware methods like :func:`numpy.nansum` (:issue:`19629`)
10821121

10831122
Strings
10841123
^^^^^^^
@@ -1094,6 +1133,7 @@ Interval
10941133
- Bug in the ``IntervalIndex`` repr where a trailing comma was missing after the list of intervals (:issue:`20611`)
10951134
- Bug in :class:`Interval` where scalar arithmetic operations did not retain the ``closed`` value (:issue:`22313`)
10961135
- Bug in :class:`IntervalIndex` where indexing with datetime-like values raised a ``KeyError`` (:issue:`20636`)
1136+
- Bug in ``IntervalTree`` where data containing ``NaN`` triggered a warning and resulted in incorrect indexing queries with :class:`IntervalIndex` (:issue:`23352`)
10971137

10981138
Indexing
10991139
^^^^^^^^

pandas/__init__.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,11 @@
4545
from pandas.core.computation.api import *
4646
from pandas.core.reshape.api import *
4747

48-
# deprecate tools.plotting, plot_params and scatter_matrix on the top namespace
49-
import pandas.tools.plotting
50-
plot_params = pandas.plotting._style._Options(deprecated=True)
51-
# do not import deprecate to top namespace
52-
scatter_matrix = pandas.util._decorators.deprecate(
53-
'pandas.scatter_matrix', pandas.plotting.scatter_matrix, '0.20.0',
54-
'pandas.plotting.scatter_matrix')
55-
5648
from pandas.util._print_versions import show_versions
5749
from pandas.io.api import *
5850
from pandas.util._tester import test
5951
import pandas.testing
6052

61-
# extension module deprecations
62-
from pandas.util._depr_module import _DeprecatedModule
63-
64-
parser = _DeprecatedModule(deprmod='pandas.parser',
65-
removals=['na_values'],
66-
moved={'CParserError': 'pandas.errors.ParserError'})
67-
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto=False,
68-
moved={'Timestamp': 'pandas.Timestamp',
69-
'Timedelta': 'pandas.Timedelta',
70-
'NaT': 'pandas.NaT',
71-
'infer_dtype': 'pandas.api.types.infer_dtype'})
72-
tslib = _DeprecatedModule(deprmod='pandas.tslib',
73-
moved={'Timestamp': 'pandas.Timestamp',
74-
'Timedelta': 'pandas.Timedelta',
75-
'NaT': 'pandas.NaT',
76-
'NaTType': 'type(pandas.NaT)',
77-
'OutOfBoundsDatetime': 'pandas.errors.OutOfBoundsDatetime'})
78-
7953
# use the closest tagged version if possible
8054
from ._version import get_versions
8155
v = get_versions()

pandas/_libs/intervaltree.pxi.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ cdef class IntervalTree(IntervalMixin):
7272

7373
self.closed = closed
7474

75+
# GH 23352: ensure no nan in nodes
76+
mask = ~np.isnan(self.left)
77+
self.left = self.left[mask]
78+
self.right = self.right[mask]
79+
indices = indices[mask]
80+
7581
node_cls = NODE_CLASSES[str(self.dtype), closed]
7682
self.root = node_cls(self.left, self.right, indices, leaf_size)
7783

pandas/_libs/tslibs/offsets.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@ class _BaseOffset(object):
344344
return {name: kwds[name] for name in kwds if kwds[name] is not None}
345345

346346
def __add__(self, other):
347-
if getattr(other, "_typ", None) in ["datetimeindex",
348-
"series", "period"]:
347+
if getattr(other, "_typ", None) in ["datetimeindex", "periodindex",
348+
"series", "period", "dataframe"]:
349349
# defer to the other class's implementation
350350
return other + self
351351
try:

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,12 @@ class Timedelta(_Timedelta):
12131213
return other.delta * self
12141214
return NotImplemented
12151215

1216+
elif util.is_nan(other):
1217+
# i.e. np.nan, but also catch np.float64("NaN") which would
1218+
# otherwise get caught by the hasattr(other, "dtype") branch
1219+
# incorrectly return a np.timedelta64 object.
1220+
return NaT
1221+
12161222
elif hasattr(other, 'dtype'):
12171223
# ndarray-like
12181224
return other * self.to_timedelta64()
@@ -1240,6 +1246,12 @@ class Timedelta(_Timedelta):
12401246
# convert to Timedelta below
12411247
pass
12421248

1249+
elif util.is_nan(other):
1250+
# i.e. np.nan, but also catch np.float64("NaN") which would
1251+
# otherwise get caught by the hasattr(other, "dtype") branch
1252+
# incorrectly return a np.timedelta64 object.
1253+
return NaT
1254+
12431255
elif hasattr(other, 'dtype'):
12441256
return self.to_timedelta64() / other
12451257

pandas/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import re
1313
import subprocess
1414
import sys
15+
1516
from pandas.compat import PY3
1617

1718

pandas/compat/pickle_compat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ def load_reduce(self):
6060
('pandas.core.arrays', 'SparseArray'),
6161

6262
# 15477
63+
#
64+
# TODO: When FrozenNDArray is removed, add
65+
# the following lines for compat:
66+
#
67+
# ('pandas.core.base', 'FrozenNDArray'):
68+
# ('numpy', 'ndarray'),
69+
# ('pandas.core.indexes.frozen', 'FrozenNDArray'):
70+
# ('numpy', 'ndarray'),
71+
#
72+
# Afterwards, remove the current entry
73+
# for `pandas.core.base.FrozenNDArray`.
6374
('pandas.core.base', 'FrozenNDArray'):
6475
('pandas.core.indexes.frozen', 'FrozenNDArray'),
6576
('pandas.core.base', 'FrozenList'):

pandas/computation/__init__.py

Whitespace-only changes.

pandas/computation/expressions.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)