Skip to content

Commit 4b560a9

Browse files
author
Sumanau Sareen
committed
Merge remote-tracking branch 'upstream/master' into BUG-32967
2 parents ce7f3ff + 36d6583 commit 4b560a9

25 files changed

+561
-456
lines changed

ci/code_checks.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,8 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
283283
pytest -q --doctest-modules pandas/core/tools/datetimes.py
284284
RET=$(($RET + $?)) ; echo $MSG "DONE"
285285

286-
MSG='Doctests top-level reshaping functions' ; echo $MSG
287-
pytest -q --doctest-modules \
288-
pandas/core/reshape/concat.py \
289-
pandas/core/reshape/pivot.py \
290-
pandas/core/reshape/reshape.py \
291-
pandas/core/reshape/tile.py \
292-
pandas/core/reshape/melt.py \
293-
-k"-crosstab -pivot_table -cut"
286+
MSG='Doctests reshaping functions' ; echo $MSG
287+
pytest -q --doctest-modules pandas/core/reshape/
294288
RET=$(($RET + $?)) ; echo $MSG "DONE"
295289

296290
MSG='Doctests interval classes' ; echo $MSG
@@ -325,6 +319,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
325319
MSG='Doctests generic.py' ; echo $MSG
326320
pytest -q --doctest-modules pandas/core/generic.py
327321
RET=$(($RET + $?)) ; echo $MSG "DONE"
322+
323+
MSG='Doctests tseries' ; echo $MSG
324+
pytest -q --doctest-modules pandas/tseries/
325+
RET=$(($RET + $?)) ; echo $MSG "DONE"
328326
fi
329327

330328
### DOCSTRINGS ###

doc/source/whatsnew/v1.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ Indexing
341341
- Fix to preserve the ability to index with the "nearest" method with xarray's CFTimeIndex, an :class:`Index` subclass (`pydata/xarray#3751 <https://github.com/pydata/xarray/issues/3751>`_, :issue:`32905`).
342342
- Bug in :class:`Index` constructor where an unhelpful error message was raised for ``numpy`` scalars (:issue:`33017`)
343343
- Bug in :meth:`DataFrame.lookup` incorrectly raising an ``AttributeError`` when ``frame.index`` or ``frame.columns`` is not unique; this will now raise a ``ValueError`` with a helpful error message (:issue:`33041`)
344+
- Bug in :meth:`DataFrame.iloc.__setitem__` creating a new array instead of overwriting ``Categorical`` values in-place (:issue:`32831`)
344345

345346
Missing
346347
^^^^^^^

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2300,7 +2300,7 @@ def to_html(
23002300
)
23012301

23022302
# ----------------------------------------------------------------------
2303-
@Appender(info.__doc__)
2303+
@doc(info)
23042304
def info(
23052305
self, verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None
23062306
) -> None:

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ def items(self):
17231723
for h in self._info_axis:
17241724
yield h, self[h]
17251725

1726-
@Appender(items.__doc__)
1726+
@doc(items)
17271727
def iteritems(self):
17281728
return self.items()
17291729

@@ -10222,7 +10222,7 @@ def _add_series_or_dataframe_operations(cls):
1022210222
"""
1022310223
from pandas.core.window import EWM, Expanding, Rolling, Window
1022410224

10225-
@Appender(Rolling.__doc__)
10225+
@doc(Rolling)
1022610226
def rolling(
1022710227
self,
1022810228
window,
@@ -10260,14 +10260,14 @@ def rolling(
1026010260

1026110261
cls.rolling = rolling
1026210262

10263-
@Appender(Expanding.__doc__)
10263+
@doc(Expanding)
1026410264
def expanding(self, min_periods=1, center=False, axis=0):
1026510265
axis = self._get_axis_number(axis)
1026610266
return Expanding(self, min_periods=min_periods, center=center, axis=axis)
1026710267

1026810268
cls.expanding = expanding
1026910269

10270-
@Appender(EWM.__doc__)
10270+
@doc(EWM)
1027110271
def ewm(
1027210272
self,
1027310273
com=None,

pandas/core/indexes/multi.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pandas._typing import AnyArrayLike, Scalar
2222
from pandas.compat.numpy import function as nv
2323
from pandas.errors import PerformanceWarning, UnsortedIndexError
24-
from pandas.util._decorators import Appender, cache_readonly
24+
from pandas.util._decorators import Appender, cache_readonly, doc
2525

2626
from pandas.core.dtypes.cast import coerce_indexer_dtype
2727
from pandas.core.dtypes.common import (
@@ -986,7 +986,7 @@ def _engine(self):
986986
def _constructor(self):
987987
return MultiIndex.from_tuples
988988

989-
@Appender(Index._shallow_copy.__doc__)
989+
@doc(Index._shallow_copy)
990990
def _shallow_copy(
991991
self,
992992
values=None,
@@ -1098,7 +1098,7 @@ def view(self, cls=None):
10981098
result._id = self._id
10991099
return result
11001100

1101-
@Appender(Index.__contains__.__doc__)
1101+
@doc(Index.__contains__)
11021102
def __contains__(self, key: Any) -> bool:
11031103
hash(key)
11041104
try:
@@ -1119,7 +1119,7 @@ def f(l):
11191119

11201120
return any(f(l) for l in self._inferred_type_levels)
11211121

1122-
@Appender(Index.memory_usage.__doc__)
1122+
@doc(Index.memory_usage)
11231123
def memory_usage(self, deep: bool = False) -> int:
11241124
# we are overwriting our base class to avoid
11251125
# computing .values here which could materialize
@@ -1351,7 +1351,7 @@ def _set_names(self, names, level=None, validate=True):
13511351

13521352
# --------------------------------------------------------------------
13531353

1354-
@Appender(Index._get_grouper_for_level.__doc__)
1354+
@doc(Index._get_grouper_for_level)
13551355
def _get_grouper_for_level(self, mapper, level):
13561356
indexer = self.codes[level]
13571357
level_index = self.levels[level]
@@ -1462,7 +1462,7 @@ def _inferred_type_levels(self):
14621462
""" return a list of the inferred types, one for each level """
14631463
return [i.inferred_type for i in self.levels]
14641464

1465-
@Appender(Index.duplicated.__doc__)
1465+
@doc(Index.duplicated)
14661466
def duplicated(self, keep="first"):
14671467
shape = map(len, self.levels)
14681468
ids = get_group_index(self.codes, shape, sort=False, xnull=False)
@@ -1475,7 +1475,7 @@ def fillna(self, value=None, downcast=None):
14751475
"""
14761476
raise NotImplementedError("isna is not defined for MultiIndex")
14771477

1478-
@Appender(Index.dropna.__doc__)
1478+
@doc(Index.dropna)
14791479
def dropna(self, how="any"):
14801480
nans = [level_codes == -1 for level_codes in self.codes]
14811481
if how == "any":
@@ -1548,7 +1548,7 @@ def get_level_values(self, level):
15481548
values = self._get_level_values(level)
15491549
return values
15501550

1551-
@Appender(Index.unique.__doc__)
1551+
@doc(Index.unique)
15521552
def unique(self, level=None):
15531553

15541554
if level is None:
@@ -3423,7 +3423,7 @@ def _convert_can_do_setop(self, other):
34233423

34243424
# --------------------------------------------------------------------
34253425

3426-
@Appender(Index.astype.__doc__)
3426+
@doc(Index.astype)
34273427
def astype(self, dtype, copy=True):
34283428
dtype = pandas_dtype(dtype)
34293429
if is_categorical_dtype(dtype):
@@ -3498,7 +3498,7 @@ def _wrap_joined_index(self, joined, other):
34983498
names = self.names if self.names == other.names else None
34993499
return MultiIndex.from_tuples(joined, names=names)
35003500

3501-
@Appender(Index.isin.__doc__)
3501+
@doc(Index.isin)
35023502
def isin(self, values, level=None):
35033503
if level is None:
35043504
values = MultiIndex.from_tuples(values, names=self.names)._values

pandas/core/indexes/numeric.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pandas._libs import index as libindex, lib
66
from pandas._typing import Dtype, Label
7-
from pandas.util._decorators import Appender, cache_readonly
7+
from pandas.util._decorators import cache_readonly, doc
88

99
from pandas.core.dtypes.cast import astype_nansafe
1010
from pandas.core.dtypes.common import (
@@ -95,14 +95,14 @@ def _validate_dtype(cls, dtype: Dtype) -> None:
9595
f"Incorrect `dtype` passed: expected {expected}, received {dtype}"
9696
)
9797

98-
@Appender(Index._maybe_cast_slice_bound.__doc__)
98+
@doc(Index._maybe_cast_slice_bound)
9999
def _maybe_cast_slice_bound(self, label, side, kind):
100100
assert kind in ["loc", "getitem", None]
101101

102102
# we will try to coerce to integers
103103
return self._maybe_cast_indexer(label)
104104

105-
@Appender(Index._shallow_copy.__doc__)
105+
@doc(Index._shallow_copy)
106106
def _shallow_copy(self, values=None, name: Label = lib.no_default):
107107
if values is not None and not self._can_hold_na and values.dtype.kind == "f":
108108
name = self.name if name is lib.no_default else name
@@ -158,7 +158,7 @@ def is_all_dates(self) -> bool:
158158
"""
159159
return False
160160

161-
@Appender(Index.insert.__doc__)
161+
@doc(Index.insert)
162162
def insert(self, loc: int, item):
163163
# treat NA values as nans:
164164
if is_scalar(item) and isna(item):
@@ -295,7 +295,7 @@ class UInt64Index(IntegerIndex):
295295
_engine_type = libindex.UInt64Engine
296296
_default_dtype = np.dtype(np.uint64)
297297

298-
@Appender(Index._convert_arr_indexer.__doc__)
298+
@doc(Index._convert_arr_indexer)
299299
def _convert_arr_indexer(self, keyarr):
300300
# Cast the indexer to uint64 if possible so that the values returned
301301
# from indexing are also uint64.
@@ -307,7 +307,7 @@ def _convert_arr_indexer(self, keyarr):
307307

308308
return com.asarray_tuplesafe(keyarr, dtype=dtype)
309309

310-
@Appender(Index._convert_index_indexer.__doc__)
310+
@doc(Index._convert_index_indexer)
311311
def _convert_index_indexer(self, keyarr):
312312
# Cast the indexer to uint64 if possible so
313313
# that the values returned from indexing are
@@ -357,7 +357,7 @@ def inferred_type(self) -> str:
357357
"""
358358
return "floating"
359359

360-
@Appender(Index.astype.__doc__)
360+
@doc(Index.astype)
361361
def astype(self, dtype, copy=True):
362362
dtype = pandas_dtype(dtype)
363363
if needs_i8_conversion(dtype):
@@ -375,11 +375,11 @@ def astype(self, dtype, copy=True):
375375
# ----------------------------------------------------------------
376376
# Indexing Methods
377377

378-
@Appender(Index._should_fallback_to_positional.__doc__)
378+
@doc(Index._should_fallback_to_positional)
379379
def _should_fallback_to_positional(self):
380380
return False
381381

382-
@Appender(Index._convert_slice_indexer.__doc__)
382+
@doc(Index._convert_slice_indexer)
383383
def _convert_slice_indexer(self, key: slice, kind: str):
384384
assert kind in ["loc", "getitem"]
385385

@@ -433,7 +433,7 @@ def __contains__(self, other: Any) -> bool:
433433

434434
return is_float(other) and np.isnan(other) and self.hasnans
435435

436-
@Appender(Index.get_loc.__doc__)
436+
@doc(Index.get_loc)
437437
def get_loc(self, key, method=None, tolerance=None):
438438
if is_bool(key):
439439
# Catch this to avoid accidentally casting to 1.0
@@ -453,7 +453,7 @@ def get_loc(self, key, method=None, tolerance=None):
453453
def is_unique(self) -> bool:
454454
return super().is_unique and self._nan_idxs.size < 2
455455

456-
@Appender(Index.isin.__doc__)
456+
@doc(Index.isin)
457457
def isin(self, values, level=None):
458458
if level is not None:
459459
self._validate_index_level(level)

pandas/core/indexes/period.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas._libs.tslibs.parsing import parse_time_string
1111
from pandas._libs.tslibs.period import Period
1212
from pandas._typing import DtypeObj, Label
13-
from pandas.util._decorators import Appender, cache_readonly
13+
from pandas.util._decorators import Appender, cache_readonly, doc
1414

1515
from pandas.core.dtypes.common import (
1616
ensure_platform_int,
@@ -327,7 +327,7 @@ def _engine(self):
327327
period = weakref.ref(self)
328328
return self._engine_type(period, len(self))
329329

330-
@Appender(Index.__contains__.__doc__)
330+
@doc(Index.__contains__)
331331
def __contains__(self, key: Any) -> bool:
332332
if isinstance(key, Period):
333333
if key.freq != self.freq:
@@ -405,7 +405,7 @@ def asof_locs(self, where, mask: np.ndarray) -> np.ndarray:
405405

406406
return result
407407

408-
@Appender(Index.astype.__doc__)
408+
@doc(Index.astype)
409409
def astype(self, dtype, copy=True, how="start"):
410410
dtype = pandas_dtype(dtype)
411411

pandas/core/indexes/range.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pandas._typing import Label
1212
import pandas.compat as compat
1313
from pandas.compat.numpy import function as nv
14-
from pandas.util._decorators import Appender, cache_readonly
14+
from pandas.util._decorators import Appender, cache_readonly, doc
1515

1616
from pandas.core.dtypes.common import (
1717
ensure_platform_int,
@@ -342,7 +342,7 @@ def __contains__(self, key: Any) -> bool:
342342
return False
343343
return key in self._range
344344

345-
@Appender(Int64Index.get_loc.__doc__)
345+
@doc(Int64Index.get_loc)
346346
def get_loc(self, key, method=None, tolerance=None):
347347
if method is None and tolerance is None:
348348
if is_integer(key) or (is_float(key) and key.is_integer()):
@@ -386,7 +386,7 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
386386
def tolist(self):
387387
return list(self._range)
388388

389-
@Appender(Int64Index._shallow_copy.__doc__)
389+
@doc(Int64Index._shallow_copy)
390390
def _shallow_copy(self, values=None, name: Label = no_default):
391391
name = self.name if name is no_default else name
392392

@@ -397,7 +397,7 @@ def _shallow_copy(self, values=None, name: Label = no_default):
397397
else:
398398
return Int64Index._simple_new(values, name=name)
399399

400-
@Appender(Int64Index.copy.__doc__)
400+
@doc(Int64Index.copy)
401401
def copy(self, name=None, deep=False, dtype=None, **kwargs):
402402
self._validate_dtype(dtype)
403403
if name is None:
@@ -619,7 +619,7 @@ def _union(self, other, sort):
619619
return type(self)(start_r, end_r + step_o, step_o)
620620
return self._int64index._union(other, sort=sort)
621621

622-
@Appender(Int64Index.join.__doc__)
622+
@doc(Int64Index.join)
623623
def join(self, other, how="left", level=None, return_indexers=False, sort=False):
624624
if how == "outer" and self is not other:
625625
# note: could return RangeIndex in more circumstances

pandas/core/indexes/timedeltas.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from pandas._libs import NaT, Timedelta, index as libindex
44
from pandas._typing import DtypeObj, Label
5-
from pandas.util._decorators import Appender
5+
from pandas.util._decorators import doc
66

77
from pandas.core.dtypes.common import (
88
_TD_DTYPE,
@@ -195,7 +195,7 @@ def _formatter_func(self):
195195

196196
# -------------------------------------------------------------------
197197

198-
@Appender(Index.astype.__doc__)
198+
@doc(Index.astype)
199199
def astype(self, dtype, copy=True):
200200
dtype = pandas_dtype(dtype)
201201
if is_timedelta64_dtype(dtype) and not is_timedelta64_ns_dtype(dtype):

pandas/core/resample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pandas._libs.tslibs.period import IncompatibleFrequency
1212
from pandas.compat.numpy import function as nv
1313
from pandas.errors import AbstractMethodError
14-
from pandas.util._decorators import Appender, Substitution
14+
from pandas.util._decorators import Appender, Substitution, doc
1515

1616
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
1717

@@ -858,7 +858,7 @@ def var(self, ddof=1, *args, **kwargs):
858858
nv.validate_resampler_func("var", args, kwargs)
859859
return self._downsample("var", ddof=ddof)
860860

861-
@Appender(GroupBy.size.__doc__)
861+
@doc(GroupBy.size)
862862
def size(self):
863863
result = self._downsample("size")
864864
if not len(self.ax):
@@ -871,7 +871,7 @@ def size(self):
871871
result = Series([], index=result.index, dtype="int64", name=name)
872872
return result
873873

874-
@Appender(GroupBy.count.__doc__)
874+
@doc(GroupBy.count)
875875
def count(self):
876876
result = self._downsample("count")
877877
if not len(self.ax):

0 commit comments

Comments
 (0)