Skip to content

Commit 881fc60

Browse files
committed
Merge branch '1.0.x' of https://github.com/pandas-dev/pandas into 1.0.x
2 parents 085060e + 0489c2f commit 881fc60

File tree

100 files changed

+1596
-360
lines changed

Some content is hidden

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

100 files changed

+1596
-360
lines changed

doc/redirects.csv

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ developer,development/developer
4646
extending,development/extending
4747
internals,development/internals
4848

49-
# api
49+
# api moved function
50+
reference/api/pandas.io.json.json_normalize,pandas.json_normalize
51+
52+
# api rename
5053
api,reference/index
5154
generated/pandas.api.extensions.ExtensionArray.argsort,../reference/api/pandas.api.extensions.ExtensionArray.argsort
5255
generated/pandas.api.extensions.ExtensionArray.astype,../reference/api/pandas.api.extensions.ExtensionArray.astype

doc/source/_static/css/pandas.css

-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
/*min-height: 150px; */
1313
}
1414

15-
.intro-card .card-img-top {
16-
margin: 10px;
17-
}
18-
1915
.custom-button {
2016
background-color: #dcdcdc;
2117
border: none;

doc/source/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
"external_links": [],
209209
"github_url": "https://github.com/pandas-dev/pandas",
210210
"twitter_url": "https://twitter.com/pandas_dev",
211+
"google_analytics_id": "UA-27880019-2",
211212
}
212213

213214
# Add any paths that contain custom themes here, relative to this directory.

doc/source/reference/extensions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ behaves correctly.
6666
.. autosummary::
6767
:toctree: api/
6868

69-
api.indexers.check_bool_array_indexer
69+
api.indexers.check_array_indexer
7070

7171

7272
The sentinel ``pandas.api.extensions.no_default`` is used as the default

doc/source/whatsnew/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Version 1.0
1717
:maxdepth: 2
1818

1919
v1.0.0
20+
v1.0.1
2021

2122
Version 0.25
2223
------------

doc/source/whatsnew/v1.0.0.rst

+138-79
Large diffs are not rendered by default.

doc/source/whatsnew/v1.0.1.rst

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
.. _whatsnew_101:
2+
3+
What's new in 1.0.1 (February 5, 2020)
4+
--------------------------------------
5+
6+
These are the changes in pandas 1.0.1. See :ref:`release` for a full changelog
7+
including other versions of pandas.
8+
9+
{{ header }}
10+
11+
.. ---------------------------------------------------------------------------
12+
13+
.. _whatsnew_101.regressions:
14+
15+
Fixed regressions
16+
~~~~~~~~~~~~~~~~~
17+
18+
- Fixed regression in :class:`DataFrame` setting values with a slice (e.g. ``df[-4:] = 1``) indexing by label instead of position (:issue:`31469`)
19+
- Fixed regression when indexing a ``Series`` or ``DataFrame`` indexed by ``DatetimeIndex`` with a slice containg a :class:`datetime.date` (:issue:`31501`)
20+
- Fixed regression in ``DataFrame.__setitem__`` raising an ``AttributeError`` with a :class:`MultiIndex` and a non-monotonic indexer (:issue:`31449`)
21+
- Fixed regression in :class:`Series` multiplication when multiplying a numeric :class:`Series` with >10000 elements with a timedelta-like scalar (:issue:`31457`)
22+
- Fixed regression in ``.groupby().agg()`` raising an ``AssertionError`` for some reductions like ``min`` on object-dtype columns (:issue:`31522`)
23+
- Fixed regression in ``.groupby()`` aggregations with categorical dtype using Cythonized reduction functions (e.g. ``first``) (:issue:`31450`)
24+
- Fixed regression in :meth:`GroupBy.apply` if called with a function which returned a non-pandas non-scalar object (e.g. a list or numpy array) (:issue:`31441`)
25+
- Fixed regression in :meth:`DataFrame.groupby` whereby taking the minimum or maximum of a column with period dtype would raise a ``TypeError``. (:issue:`31471`)
26+
- Fixed regression in :meth:`DataFrame.groupby` with an empty DataFrame grouping by a level of a MultiIndex (:issue:`31670`).
27+
- Fixed regression in :meth:`DataFrame.apply` with object dtype and non-reducing function (:issue:`31505`)
28+
- Fixed regression in :meth:`to_datetime` when parsing non-nanosecond resolution datetimes (:issue:`31491`)
29+
- Fixed regression in :meth:`~DataFrame.to_csv` where specifying an ``na_rep`` might truncate the values written (:issue:`31447`)
30+
- Fixed regression in :class:`Categorical` construction with ``numpy.str_`` categories (:issue:`31499`)
31+
- Fixed regression in :meth:`DataFrame.loc` and :meth:`DataFrame.iloc` when selecting a row containing a single ``datetime64`` or ``timedelta64`` column (:issue:`31649`)
32+
- Fixed regression where setting :attr:`pd.options.display.max_colwidth` was not accepting negative integer. In addition, this behavior has been deprecated in favor of using ``None`` (:issue:`31532`)
33+
- Fixed regression in objTOJSON.c fix return-type warning (:issue:`31463`)
34+
- Fixed regression in :meth:`qcut` when passed a nullable integer. (:issue:`31389`)
35+
- Fixed regression in assigning to a :class:`Series` using a nullable integer dtype (:issue:`31446`)
36+
- Fixed performance regression when indexing a ``DataFrame`` or ``Series`` with a :class:`MultiIndex` for the index using a list of labels (:issue:`31648`)
37+
- Fixed regression in :meth:`read_csv` used in file like object ``RawIOBase`` is not recognize ``encoding`` option (:issue:`31575`)
38+
39+
.. ---------------------------------------------------------------------------
40+
41+
.. _whatsnew_101.deprecations:
42+
43+
Deprecations
44+
~~~~~~~~~~~~
45+
46+
- Support for negative integer for :attr:`pd.options.display.max_colwidth` is deprecated in favor of using ``None`` (:issue:`31532`)
47+
48+
.. ---------------------------------------------------------------------------
49+
50+
.. _whatsnew_101.bug_fixes:
51+
52+
Bug fixes
53+
~~~~~~~~~
54+
55+
**Datetimelike**
56+
57+
- Fixed bug in :meth:`to_datetime` raising when ``cache=True`` and out-of-bound values are present (:issue:`31491`)
58+
59+
**Numeric**
60+
61+
- Bug in dtypes being lost in ``DataFrame.__invert__`` (``~`` operator) with mixed dtypes (:issue:`31183`)
62+
and for extension-array backed ``Series`` and ``DataFrame`` (:issue:`23087`)
63+
64+
**Plotting**
65+
66+
- Plotting tz-aware timeseries no longer gives UserWarning (:issue:`31205`)
67+
68+
**Interval**
69+
70+
- Bug in :meth:`Series.shift` with ``interval`` dtype raising a ``TypeError`` when shifting an interval array of integers or datetimes (:issue:`34195`)
71+
72+
.. ---------------------------------------------------------------------------
73+
74+
.. _whatsnew_101.contributors:
75+
76+
Contributors
77+
~~~~~~~~~~~~
78+
79+
.. contributors:: v1.0.0..v1.0.1|HEAD

doc/sphinxext/announce.py

+10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ def get_authors(revision_range):
5757
pat = "^.*\\t(.*)$"
5858
lst_release, cur_release = [r.strip() for r in revision_range.split("..")]
5959

60+
if "|" in cur_release:
61+
# e.g. v1.0.1|HEAD
62+
maybe_tag, head = cur_release.split("|")
63+
assert head == "HEAD"
64+
if maybe_tag in this_repo.tags:
65+
cur_release = maybe_tag
66+
else:
67+
cur_release = head
68+
revision_range = f"{lst_release}..{cur_release}"
69+
6070
# authors, in current release and previous to current release.
6171
cur = set(re.findall(pat, this_repo.git.shortlog("-s", revision_range), re.M))
6272
pre = set(re.findall(pat, this_repo.git.shortlog("-s", lst_release), re.M))

doc/sphinxext/contributors.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
77
This will be replaced with a message indicating the number of
88
code contributors and commits, and then list each contributor
9-
individually.
9+
individually. For development versions (before a tag is available)
10+
use::
11+
12+
.. contributors:: v0.23.0..v0.23.1|HEAD
13+
14+
While the v0.23.1 tag does not exist, that will use the HEAD of the
15+
branch as the end of the revision range.
1016
"""
1117
from announce import build_components
1218
from docutils import nodes

pandas/_config/config.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def _describe_option(pat="", _print_desc=True):
144144
if len(keys) == 0:
145145
raise OptionError("No such keys(s)")
146146

147-
s = ""
148-
for k in keys: # filter by pat
149-
s += _build_option_description(k)
147+
s = "\n".join([_build_option_description(k) for k in keys])
150148

151149
if _print_desc:
152150
print(s)

pandas/_libs/hashtable_class_helper.pxi.in

+6-2
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@ cdef class StringHashTable(HashTable):
670670
val = values[i]
671671

672672
if isinstance(val, str):
673-
v = get_c_string(val)
673+
# GH#31499 if we have a np.str_ get_c_string wont recognize
674+
# it as a str, even though isinstance does.
675+
v = get_c_string(<str>val)
674676
else:
675677
v = get_c_string(self.na_string_sentinel)
676678
vecs[i] = v
@@ -703,7 +705,9 @@ cdef class StringHashTable(HashTable):
703705
val = values[i]
704706

705707
if isinstance(val, str):
706-
v = get_c_string(val)
708+
# GH#31499 if we have a np.str_ get_c_string wont recognize
709+
# it as a str, even though isinstance does.
710+
v = get_c_string(<str>val)
707711
else:
708712
v = get_c_string(self.na_string_sentinel)
709713
vecs[i] = v

pandas/_libs/parsers.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ cdef class TextReader:
638638
raise ValueError(f'Unrecognized compression type: '
639639
f'{self.compression}')
640640

641-
if self.encoding and isinstance(source, io.BufferedIOBase):
641+
if self.encoding and isinstance(source, (io.BufferedIOBase, io.RawIOBase)):
642642
source = io.TextIOWrapper(
643643
source, self.encoding.decode('utf-8'), newline='')
644644

pandas/_libs/reduction.pyx

+4-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ cdef class Reducer:
114114
if self.typ is not None:
115115
# In this case, we also have self.index
116116
name = labels[i]
117-
cached_typ = self.typ(chunk, index=self.index, name=name)
117+
cached_typ = self.typ(
118+
chunk, index=self.index, name=name, dtype=arr.dtype)
118119

119120
# use the cached_typ if possible
120121
if cached_typ is not None:
@@ -501,9 +502,9 @@ def apply_frame_axis0(object frame, object f, object names,
501502

502503
if not is_scalar(piece):
503504
# Need to copy data to avoid appending references
504-
if hasattr(piece, "copy"):
505+
try:
505506
piece = piece.copy(deep="all")
506-
else:
507+
except (TypeError, AttributeError):
507508
piece = copy(piece)
508509

509510
results.append(piece)

pandas/_libs/src/ujson/python/objToJSON.c

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ void *initObjToJSON(void) {
178178

179179
/* Initialise numpy API */
180180
import_array();
181+
// GH 31463
182+
return NULL;
181183
}
182184

183185
static TypeContext *createTypeContext(void) {

pandas/api/indexers/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Public API for Rolling Window Indexers.
33
"""
44

5-
from pandas.core.indexers import check_bool_array_indexer
5+
from pandas.core.indexers import check_array_indexer
66
from pandas.core.window.indexers import BaseIndexer
77

8-
__all__ = ["check_bool_array_indexer", "BaseIndexer"]
8+
__all__ = ["check_array_indexer", "BaseIndexer"]

pandas/core/algorithms.py

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
is_categorical_dtype,
3030
is_complex_dtype,
3131
is_datetime64_any_dtype,
32+
is_datetime64_dtype,
3233
is_datetime64_ns_dtype,
3334
is_extension_array_dtype,
3435
is_float_dtype,
@@ -191,6 +192,11 @@ def _reconstruct_data(values, dtype, original):
191192
if isinstance(original, ABCIndexClass):
192193
values = values.astype(object, copy=False)
193194
elif dtype is not None:
195+
if is_datetime64_dtype(dtype):
196+
dtype = "datetime64[ns]"
197+
elif is_timedelta64_dtype(dtype):
198+
dtype = "timedelta64[ns]"
199+
194200
values = values.astype(dtype, copy=False)
195201

196202
return values

pandas/core/apply.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
is_list_like,
1414
is_sequence,
1515
)
16-
from pandas.core.dtypes.generic import ABCMultiIndex, ABCSeries
16+
from pandas.core.dtypes.generic import ABCSeries
1717

1818
from pandas.core.construction import create_series_with_explicit_dtype
1919

@@ -277,9 +277,8 @@ def apply_standard(self):
277277
if (
278278
self.result_type in ["reduce", None]
279279
and not self.dtypes.apply(is_extension_array_dtype).any()
280-
# Disallow complex_internals since libreduction shortcut
281-
# cannot handle MultiIndex
282-
and not isinstance(self.agg_axis, ABCMultiIndex)
280+
# Disallow complex_internals since libreduction shortcut raises a TypeError
281+
and not self.agg_axis._has_complex_internals
283282
):
284283

285284
values = self.values

pandas/core/arrays/boolean.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pandas.core.dtypes.missing import isna, notna
2727

2828
from pandas.core import nanops, ops
29+
from pandas.core.indexers import check_array_indexer
2930

3031
from .masked import BaseMaskedArray
3132

@@ -369,6 +370,7 @@ def __setitem__(self, key, value):
369370
value = value[0]
370371
mask = mask[0]
371372

373+
key = check_array_indexer(self, key)
372374
self._data[key] = value
373375
self._mask[key] = mask
374376

pandas/core/arrays/categorical.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from pandas.core.dtypes.dtypes import CategoricalDtype
4141
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
42-
from pandas.core.dtypes.inference import is_array_like, is_hashable
42+
from pandas.core.dtypes.inference import is_hashable
4343
from pandas.core.dtypes.missing import isna, notna
4444

4545
from pandas.core import ops
@@ -54,7 +54,7 @@
5454
from pandas.core.base import NoNewAttributesMixin, PandasObject, _shared_docs
5555
import pandas.core.common as com
5656
from pandas.core.construction import array, extract_array, sanitize_array
57-
from pandas.core.indexers import check_bool_array_indexer
57+
from pandas.core.indexers import check_array_indexer, deprecate_ndim_indexing
5858
from pandas.core.missing import interpolate_2d
5959
from pandas.core.ops.common import unpack_zerodim_and_defer
6060
from pandas.core.sorting import nargsort
@@ -2001,14 +2001,11 @@ def __getitem__(self, key):
20012001
else:
20022002
return self.categories[i]
20032003

2004-
if is_list_like(key) and not is_array_like(key):
2005-
key = np.asarray(key)
2006-
2007-
if com.is_bool_indexer(key):
2008-
key = check_bool_array_indexer(self, key)
2004+
key = check_array_indexer(self, key)
20092005

20102006
result = self._codes[key]
20112007
if result.ndim > 1:
2008+
deprecate_ndim_indexing(result)
20122009
return result
20132010
return self._constructor(result, dtype=self.dtype, fastpath=True)
20142011

@@ -2076,6 +2073,8 @@ def __setitem__(self, key, value):
20762073

20772074
lindexer = self.categories.get_indexer(rvalue)
20782075
lindexer = self._maybe_coerce_indexer(lindexer)
2076+
2077+
key = check_array_indexer(self, key)
20792078
self._codes[key] = lindexer
20802079

20812080
def _reverse_indexer(self) -> Dict[Hashable, np.ndarray]:

pandas/core/arrays/datetimelike.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from pandas.core.algorithms import checked_add_with_arr, take, unique1d, value_counts
4343
from pandas.core.arrays.base import ExtensionArray, ExtensionOpsMixin
4444
import pandas.core.common as com
45-
from pandas.core.indexers import check_bool_array_indexer
45+
from pandas.core.indexers import check_array_indexer
4646
from pandas.core.ops.common import unpack_zerodim_and_defer
4747
from pandas.core.ops.invalid import invalid_comparison, make_invalid_op
4848

@@ -518,11 +518,20 @@ def __getitem__(self, key):
518518
return type(self)(val, dtype=self.dtype)
519519

520520
if com.is_bool_indexer(key):
521-
key = check_bool_array_indexer(self, key)
521+
# first convert to boolean, because check_array_indexer doesn't
522+
# allow object dtype
523+
key = np.asarray(key, dtype=bool)
524+
key = check_array_indexer(self, key)
522525
if key.all():
523526
key = slice(0, None, None)
524527
else:
525528
key = lib.maybe_booleans_to_slice(key.view(np.uint8))
529+
elif isinstance(key, list) and len(key) == 1 and isinstance(key[0], slice):
530+
# see https://github.com/pandas-dev/pandas/issues/31299, need to allow
531+
# this for now (would otherwise raise in check_array_indexer)
532+
pass
533+
else:
534+
key = check_array_indexer(self, key)
526535

527536
is_period = is_period_dtype(self)
528537
if is_period:
@@ -592,6 +601,8 @@ def __setitem__(
592601
f"or array of those. Got '{type(value).__name__}' instead."
593602
)
594603
raise TypeError(msg)
604+
605+
key = check_array_indexer(self, key)
595606
self._data[key] = value
596607
self._maybe_clear_freq()
597608

pandas/core/arrays/integer.py

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pandas.core.dtypes.missing import isna
2626

2727
from pandas.core import nanops, ops
28+
from pandas.core.indexers import check_array_indexer
2829
from pandas.core.ops import invalid_comparison
2930
from pandas.core.ops.common import unpack_zerodim_and_defer
3031
from pandas.core.tools.numeric import to_numeric
@@ -414,6 +415,7 @@ def __setitem__(self, key, value):
414415
value = value[0]
415416
mask = mask[0]
416417

418+
key = check_array_indexer(self, key)
417419
self._data[key] = value
418420
self._mask[key] = mask
419421

0 commit comments

Comments
 (0)