Skip to content

Commit efae1bf

Browse files
committed
Back to pre updated subset docstring commit
1 parent da41988 commit efae1bf

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

pandas/core/frame.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import functools
1717
from io import StringIO
1818
import itertools
19+
import sys
1920
from textwrap import dedent
2021
from typing import (
2122
TYPE_CHECKING,
@@ -48,7 +49,7 @@
4849
from pandas._libs.hashtable import duplicated
4950
from pandas._libs.lib import (
5051
NoDefault,
51-
array_equal_fast,
52+
is_range_indexer,
5253
no_default,
5354
)
5455
from pandas._typing import (
@@ -91,12 +92,17 @@
9192
WriteBuffer,
9293
npt,
9394
)
95+
from pandas.compat import PYPY
9496
from pandas.compat._optional import import_optional_dependency
9597
from pandas.compat.numpy import (
9698
function as nv,
9799
np_percentile_argname,
98100
)
99-
from pandas.errors import InvalidIndexError
101+
from pandas.errors import (
102+
ChainedAssignmentError,
103+
InvalidIndexError,
104+
_chained_assignment_msg,
105+
)
100106
from pandas.util._decorators import (
101107
Appender,
102108
Substitution,
@@ -3862,6 +3868,10 @@ def isetitem(self, loc, value) -> None:
38623868
self._iset_item_mgr(loc, arraylike, inplace=False)
38633869

38643870
def __setitem__(self, key, value):
3871+
if not PYPY and using_copy_on_write():
3872+
if sys.getrefcount(self) <= 3:
3873+
raise ChainedAssignmentError(_chained_assignment_msg)
3874+
38653875
key = com.apply_if_callable(key, self)
38663876

38673877
# see if we can slice the rows
@@ -6724,7 +6734,7 @@ def sort_values(
67246734
else:
67256735
return self.copy(deep=None)
67266736

6727-
if array_equal_fast(indexer, np.arange(0, len(indexer), dtype=indexer.dtype)):
6737+
if is_range_indexer(indexer, len(indexer)):
67286738
if inplace:
67296739
return self._update_inplace(self)
67306740
else:
@@ -6922,8 +6932,8 @@ def value_counts(
69226932
69236933
Parameters
69246934
----------
6925-
subset : label or list of labels, optional
6926-
Column(s) to use when counting unique combinations.
6935+
subset : mapping, function, label, list of labels, optional
6936+
Columns to use when counting unique combinations.
69276937
normalize : bool, default False
69286938
Return proportions rather than frequencies.
69296939
sort : bool, default True
@@ -10877,11 +10887,7 @@ def quantile(
1087710887
f"Invalid method: {method}. Method must be in {valid_method}."
1087810888
)
1087910889
if method == "single":
10880-
# error: Argument "qs" to "quantile" of "BlockManager" has incompatible type
10881-
# "Index"; expected "Float64Index"
10882-
res = data._mgr.quantile(
10883-
qs=q, axis=1, interpolation=interpolation # type: ignore[arg-type]
10884-
)
10890+
res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation)
1088510891
elif method == "table":
1088610892
valid_interpolation = {"nearest", "lower", "higher"}
1088710893
if interpolation not in valid_interpolation:

0 commit comments

Comments
 (0)