Skip to content

Commit 3d34aff

Browse files
Merge remote-tracking branch 'upstream/master' into bisect
2 parents 979b5f2 + 36c4d5c commit 3d34aff

File tree

89 files changed

+1060
-682
lines changed

Some content is hidden

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

89 files changed

+1060
-682
lines changed

ci/deps/azure-38.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ dependencies:
1717
- python-dateutil
1818
- nomkl
1919
- pytz
20-
- tabulate==0.8.3
20+
- tabulate==0.8.7

doc/source/getting_started/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pyreadstat SPSS files (.sav) reading
283283
pyxlsb 1.0.6 Reading for xlsb files
284284
qtpy Clipboard I/O
285285
s3fs 0.4.0 Amazon S3 access
286-
tabulate 0.8.3 Printing in Markdown-friendly format (see `tabulate`_)
286+
tabulate 0.8.7 Printing in Markdown-friendly format (see `tabulate`_)
287287
xarray 0.12.3 pandas-like API for N-dimensional data
288288
xclip Clipboard I/O on linux
289289
xlrd 1.2.0 Excel reading

doc/source/reference/indexing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ MultiIndex properties
290290
MultiIndex.codes
291291
MultiIndex.nlevels
292292
MultiIndex.levshape
293+
MultiIndex.dtypes
293294

294295
MultiIndex components
295296
~~~~~~~~~~~~~~~~~~~~~

doc/source/whatsnew/v1.2.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Other enhancements
308308
- Improved error reporting for subsetting columns of a :class:`.DataFrameGroupBy` with ``axis=1`` (:issue:`37725`)
309309
- Implement method ``cross`` for :meth:`DataFrame.merge` and :meth:`DataFrame.join` (:issue:`5401`)
310310
- When :func:`read_csv/sas/json` are called with ``chuncksize``/``iterator`` they can be used in a ``with`` statement as they return context-managers (:issue:`38225`)
311+
- Augmented the list of named colors available for styling Excel exports, enabling all of CSS4 colors (:issue:`38247`)
311312

312313
.. ---------------------------------------------------------------------------
313314
@@ -606,6 +607,7 @@ Datetimelike
606607
- Bug in :meth:`Series.isin` with ``datetime64[ns]`` dtype and :meth:`.DatetimeIndex.isin` failing to consider timezone-aware and timezone-naive datetimes as always different (:issue:`35728`)
607608
- Bug in :meth:`Series.isin` with ``PeriodDtype`` dtype and :meth:`PeriodIndex.isin` failing to consider arguments with different ``PeriodDtype`` as always different (:issue:`37528`)
608609
- Bug in :class:`Period` constructor now correctly handles nanoseconds in the ``value`` argument (:issue:`34621` and :issue:`17053`)
610+
- Bug in :meth:`DataFrame.first` and :meth:`Series.first` returning two months for offset one month when first day is last calendar day (:issue:`29623`)
609611

610612
Timedelta
611613
^^^^^^^^^

doc/source/whatsnew/v1.3.0.rst

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Enhancements
1919
Other enhancements
2020
^^^^^^^^^^^^^^^^^^
2121

22-
-
22+
- Added :meth:`MultiIndex.dtypes` (:issue:`37062`)
2323
-
2424

2525
.. ---------------------------------------------------------------------------
@@ -37,7 +37,76 @@ These are bug fixes that might have notable behavior changes.
3737

3838
Increased minimum versions for dependencies
3939
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40-
40+
Some minimum supported versions of dependencies were updated.
41+
If installed, we now require:
42+
43+
+-----------------+-----------------+----------+---------+
44+
| Package | Minimum Version | Required | Changed |
45+
+=================+=================+==========+=========+
46+
| numpy | 1.16.5 | X | |
47+
+-----------------+-----------------+----------+---------+
48+
| pytz | 2017.3 | X | |
49+
+-----------------+-----------------+----------+---------+
50+
| python-dateutil | 2.7.3 | X | |
51+
+-----------------+-----------------+----------+---------+
52+
| bottleneck | 1.2.1 | | |
53+
+-----------------+-----------------+----------+---------+
54+
| numexpr | 2.6.8 | | |
55+
+-----------------+-----------------+----------+---------+
56+
| pytest (dev) | 5.0.1 | | |
57+
+-----------------+-----------------+----------+---------+
58+
| mypy (dev) | 0.782 | | |
59+
+-----------------+-----------------+----------+---------+
60+
61+
For `optional libraries <https://dev.pandas.io/docs/install.html#dependencies>`_ the general recommendation is to use the latest version.
62+
The following table lists the lowest version per library that is currently being tested throughout the development of pandas.
63+
Optional libraries below the lowest tested version may still work, but are not considered supported.
64+
65+
+-----------------+-----------------+---------+
66+
| Package | Minimum Version | Changed |
67+
+=================+=================+=========+
68+
| beautifulsoup4 | 4.6.0 | |
69+
+-----------------+-----------------+---------+
70+
| fastparquet | 0.3.2 | |
71+
+-----------------+-----------------+---------+
72+
| fsspec | 0.7.4 | |
73+
+-----------------+-----------------+---------+
74+
| gcsfs | 0.6.0 | |
75+
+-----------------+-----------------+---------+
76+
| lxml | 4.3.0 | |
77+
+-----------------+-----------------+---------+
78+
| matplotlib | 2.2.3 | |
79+
+-----------------+-----------------+---------+
80+
| numba | 0.46.0 | |
81+
+-----------------+-----------------+---------+
82+
| openpyxl | 2.6.0 | |
83+
+-----------------+-----------------+---------+
84+
| pyarrow | 0.15.0 | |
85+
+-----------------+-----------------+---------+
86+
| pymysql | 0.7.11 | |
87+
+-----------------+-----------------+---------+
88+
| pytables | 3.5.1 | |
89+
+-----------------+-----------------+---------+
90+
| s3fs | 0.4.0 | |
91+
+-----------------+-----------------+---------+
92+
| scipy | 1.2.0 | |
93+
+-----------------+-----------------+---------+
94+
| sqlalchemy | 1.2.8 | |
95+
+-----------------+-----------------+---------+
96+
| tabulate | 0.8.7 | X |
97+
+-----------------+-----------------+---------+
98+
| xarray | 0.12.0 | |
99+
+-----------------+-----------------+---------+
100+
| xlrd | 1.2.0 | |
101+
+-----------------+-----------------+---------+
102+
| xlsxwriter | 1.0.2 | |
103+
+-----------------+-----------------+---------+
104+
| xlwt | 1.3.0 | |
105+
+-----------------+-----------------+---------+
106+
| pandas-gbq | 0.12.0 | |
107+
+-----------------+-----------------+---------+
108+
109+
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.
41110

42111
.. _whatsnew_130.api.other:
43112

@@ -86,7 +155,7 @@ Categorical
86155

87156
Datetimelike
88157
^^^^^^^^^^^^
89-
158+
- Bug in :class:`DataFrame` and :class:`Series` constructors sometimes dropping nanoseconds from :class:`Timestamp` (resp. :class:`Timedelta`) ``data``, with ``dtype=datetime64[ns]`` (resp. ``timedelta64[ns]``) (:issue:`38032`)
90159
-
91160
-
92161

@@ -127,7 +196,9 @@ Interval
127196

128197
Indexing
129198
^^^^^^^^
130-
199+
- Bug in :meth:`CategoricalIndex.get_indexer` failing to raise ``InvalidIndexError`` when non-unique (:issue:`38372`)
200+
- Bug in inserting many new columns into a :class:`DataFrame` causing incorrect subsequent indexing behavior (:issue:`38380`)
201+
- Bug in :meth:`DataFrame.iloc.__setitem__` and :meth:`DataFrame.loc.__setitem__` with mixed dtypes when setting with a dictionary value (:issue:`38335`)
131202
-
132203
-
133204

@@ -146,7 +217,7 @@ MultiIndex
146217
I/O
147218
^^^
148219

149-
-
220+
- Bug in :func:`read_csv` raising ``TypeError`` when ``names`` and ``parse_dates`` is specified for ``engine="c"`` (:issue:`33699`)
150221
-
151222

152223
Period

pandas/_libs/algos.pyx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def rank_1d(
824824
if values.dtype != np.object_:
825825
values = values.astype('O')
826826
else:
827-
values = np.asarray(in_arr)
827+
values = np.asarray(in_arr).copy()
828828

829829
keep_na = na_option == 'keep'
830830

@@ -835,11 +835,6 @@ def rank_1d(
835835
elif rank_t is int64_t:
836836
mask = values == NPY_NAT
837837

838-
# create copy in case of NPY_NAT
839-
# values are mutated inplace
840-
if mask.any():
841-
values = values.copy()
842-
843838
# double sort first by mask and then by values to ensure nan values are
844839
# either at the beginning or the end. mask/(~mask) controls padding at
845840
# tail or the head

pandas/compat/_optional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"scipy": "1.2.0",
2525
"sqlalchemy": "1.2.8",
2626
"tables": "3.5.1",
27-
"tabulate": "0.8.3",
27+
"tabulate": "0.8.7",
2828
"xarray": "0.12.3",
2929
"xlrd": "1.2.0",
3030
"xlwt": "1.3.0",

pandas/core/algorithms.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
from pandas.core.dtypes.generic import (
5151
ABCDatetimeArray,
5252
ABCExtensionArray,
53-
ABCIndexClass,
53+
ABCIndex,
5454
ABCMultiIndex,
5555
ABCRangeIndex,
5656
ABCSeries,
@@ -63,6 +63,7 @@
6363

6464
if TYPE_CHECKING:
6565
from pandas import Categorical, DataFrame, Index, Series
66+
from pandas.core.arrays import DatetimeArray, TimedeltaArray
6667

6768
_shared_docs: Dict[str, str] = {}
6869

@@ -215,7 +216,7 @@ def _reconstruct_data(
215216
values = values.astype(dtype, copy=False)
216217

217218
# we only support object dtypes bool Index
218-
if isinstance(original, ABCIndexClass):
219+
if isinstance(original, ABCIndex):
219220
values = values.astype(object, copy=False)
220221
elif dtype is not None:
221222
if is_datetime64_dtype(dtype):
@@ -437,9 +438,7 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
437438
f"to isin(), you passed a [{type(values).__name__}]"
438439
)
439440

440-
if not isinstance(
441-
values, (ABCIndexClass, ABCSeries, ABCExtensionArray, np.ndarray)
442-
):
441+
if not isinstance(values, (ABCIndex, ABCSeries, ABCExtensionArray, np.ndarray)):
443442
values = _ensure_arraylike(list(values))
444443
elif isinstance(values, ABCMultiIndex):
445444
# Avoid raising in extract_array
@@ -700,7 +699,7 @@ def factorize(
700699
and values.freq is not None
701700
):
702701
codes, uniques = values.factorize(sort=sort)
703-
if isinstance(original, ABCIndexClass):
702+
if isinstance(original, ABCIndex):
704703
uniques = original._shallow_copy(uniques, name=None)
705704
elif isinstance(original, ABCSeries):
706705
from pandas import Index
@@ -739,8 +738,11 @@ def factorize(
739738
uniques = _reconstruct_data(uniques, dtype, original)
740739

741740
# return original tenor
742-
if isinstance(original, ABCIndexClass):
741+
if isinstance(original, ABCIndex):
743742
if original.dtype.kind in ["m", "M"] and isinstance(uniques, np.ndarray):
743+
original._data = cast(
744+
"Union[DatetimeArray, TimedeltaArray]", original._data
745+
)
744746
uniques = type(original._data)._simple_new(uniques, dtype=original.dtype)
745747
uniques = original._shallow_copy(uniques, name=None)
746748
elif isinstance(original, ABCSeries):

pandas/core/arrays/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas.core.arrays.categorical import Categorical
88
from pandas.core.arrays.datetimes import DatetimeArray
99
from pandas.core.arrays.floating import FloatingArray
10-
from pandas.core.arrays.integer import IntegerArray, integer_array
10+
from pandas.core.arrays.integer import IntegerArray
1111
from pandas.core.arrays.interval import IntervalArray
1212
from pandas.core.arrays.masked import BaseMaskedArray
1313
from pandas.core.arrays.numpy_ import PandasArray, PandasDtype
@@ -26,7 +26,6 @@
2626
"DatetimeArray",
2727
"FloatingArray",
2828
"IntegerArray",
29-
"integer_array",
3029
"IntervalArray",
3130
"PandasArray",
3231
"PandasDtype",

pandas/core/arrays/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
pandas_dtype,
4242
)
4343
from pandas.core.dtypes.dtypes import ExtensionDtype
44-
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
44+
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndex, ABCSeries
4545
from pandas.core.dtypes.missing import isna
4646

4747
from pandas.core import ops
@@ -1361,7 +1361,7 @@ def convert_values(param):
13611361
ovalues = [param] * len(self)
13621362
return ovalues
13631363

1364-
if isinstance(other, (ABCSeries, ABCIndexClass, ABCDataFrame)):
1364+
if isinstance(other, (ABCSeries, ABCIndex, ABCDataFrame)):
13651365
# rely on pandas to unbox and dispatch to us
13661366
return NotImplemented
13671367

pandas/core/arrays/categorical.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
needs_i8_conversion,
3939
)
4040
from pandas.core.dtypes.dtypes import CategoricalDtype
41-
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
41+
from pandas.core.dtypes.generic import ABCIndex, ABCSeries
4242
from pandas.core.dtypes.missing import is_valid_nat_for_dtype, isna, notna
4343

4444
from pandas.core import ops
@@ -321,7 +321,7 @@ def __init__(
321321
if is_categorical_dtype(values):
322322
if dtype.categories is None:
323323
dtype = CategoricalDtype(values.categories, dtype.ordered)
324-
elif not isinstance(values, (ABCIndexClass, ABCSeries)):
324+
elif not isinstance(values, (ABCIndex, ABCSeries)):
325325
# sanitize_array coerces np.nan to a string under certain versions
326326
# of numpy
327327
values = maybe_infer_to_datetimelike(values, convert_dates=True)
@@ -2514,7 +2514,7 @@ def _get_codes_for_values(values, categories) -> np.ndarray:
25142514
values = ensure_object(values)
25152515
categories = ensure_object(categories)
25162516

2517-
if isinstance(categories, ABCIndexClass):
2517+
if isinstance(categories, ABCIndex):
25182518
return coerce_indexer_dtype(categories.get_indexer_for(values), categories)
25192519

25202520
# Only hit here when we've already coerced to object dtypee.

pandas/core/arrays/datetimes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
pandas_dtype,
4545
)
4646
from pandas.core.dtypes.dtypes import DatetimeTZDtype
47-
from pandas.core.dtypes.generic import ABCIndexClass, ABCPandasArray, ABCSeries
47+
from pandas.core.dtypes.generic import ABCIndex, ABCPandasArray, ABCSeries
4848
from pandas.core.dtypes.missing import isna
4949

5050
from pandas.core.algorithms import checked_add_with_arr
@@ -216,7 +216,7 @@ class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps):
216216
_freq = None
217217

218218
def __init__(self, values, dtype=DT64NS_DTYPE, freq=None, copy=False):
219-
if isinstance(values, (ABCSeries, ABCIndexClass)):
219+
if isinstance(values, (ABCSeries, ABCIndex)):
220220
values = values._values
221221

222222
inferred_freq = getattr(values, "_freq", None)
@@ -1947,7 +1947,7 @@ def sequence_to_dt64ns(
19471947
# if dtype has an embedded tz, capture it
19481948
tz = validate_tz_from_dtype(dtype, tz)
19491949

1950-
if isinstance(data, ABCIndexClass):
1950+
if isinstance(data, ABCIndex):
19511951
if data.nlevels > 1:
19521952
# Without this check, data._data below is None
19531953
raise TypeError("Cannot create a DatetimeArray from a MultiIndex.")

pandas/core/arrays/floating.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import numbers
2-
from typing import TYPE_CHECKING, List, Optional, Tuple, Type, Union
2+
from typing import List, Optional, Tuple, Type
33
import warnings
44

55
import numpy as np
@@ -27,13 +27,10 @@
2727
from pandas.core.tools.numeric import to_numeric
2828

2929
from .masked import BaseMaskedDtype
30-
from .numeric import NumericArray
30+
from .numeric import NumericArray, NumericDtype
3131

32-
if TYPE_CHECKING:
33-
import pyarrow
3432

35-
36-
class FloatingDtype(BaseMaskedDtype):
33+
class FloatingDtype(NumericDtype):
3734
"""
3835
An ExtensionDtype to hold a single size of floating dtype.
3936
@@ -72,34 +69,6 @@ def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]:
7269
return FLOAT_STR_TO_DTYPE[str(np_dtype)]
7370
return None
7471

75-
def __from_arrow__(
76-
self, array: Union["pyarrow.Array", "pyarrow.ChunkedArray"]
77-
) -> "FloatingArray":
78-
"""
79-
Construct FloatingArray from pyarrow Array/ChunkedArray.
80-
"""
81-
import pyarrow
82-
83-
from pandas.core.arrays._arrow_utils import pyarrow_array_to_numpy_and_mask
84-
85-
pyarrow_type = pyarrow.from_numpy_dtype(self.type)
86-
if not array.type.equals(pyarrow_type):
87-
array = array.cast(pyarrow_type)
88-
89-
if isinstance(array, pyarrow.Array):
90-
chunks = [array]
91-
else:
92-
# pyarrow.ChunkedArray
93-
chunks = array.chunks
94-
95-
results = []
96-
for arr in chunks:
97-
data, mask = pyarrow_array_to_numpy_and_mask(arr, dtype=self.type)
98-
float_arr = FloatingArray(data.copy(), ~mask, copy=False)
99-
results.append(float_arr)
100-
101-
return FloatingArray._concat_same_type(results)
102-
10372

10473
def coerce_to_array(
10574
values, dtype=None, mask=None, copy: bool = False

0 commit comments

Comments
 (0)