We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cbb6723 commit ce8c7b6Copy full SHA for ce8c7b6
pandas-stubs/core/frame.pyi
@@ -2298,7 +2298,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
2298
) -> Series: ...
2299
def swapaxes(self, axis1: Axis, axis2: Axis, copy: _bool = ...) -> Self: ...
2300
def tail(self, n: int = ...) -> Self: ...
2301
- def take(self, indices: list, axis: Axis = ..., **kwargs: Any) -> Self: ...
2302
@overload
2303
def to_json(
2304
self,
pandas-stubs/core/generic.pyi
@@ -46,6 +46,7 @@ from pandas._typing import (
46
P,
47
StorageOptions,
48
T,
49
+ TakeIndexer,
50
TimedeltaConvertibleTypes,
51
TimeGrouperOrigin,
52
TimestampConvention,
@@ -418,3 +419,5 @@ class NDFrame(indexing.IndexingMixin):
418
419
offset: TimedeltaConvertibleTypes | None = ...,
420
group_keys: _bool = ...,
421
) -> DatetimeIndexResampler[Self]: ...
422
+ @final
423
+ def take(self, indices: TakeIndexer, axis: Axis = ..., **kwargs: Any) -> Self: ...
pandas-stubs/core/series.pyi
@@ -450,9 +450,6 @@ class Series(IndexOpsMixin[S1], NDFrame):
450
def __array__(self, dtype=...) -> np.ndarray: ...
451
@property
452
def axes(self) -> list: ...
453
- def take(
454
- self, indices: Sequence, axis: AxisIndex = ..., **kwargs: Any
455
- ) -> Series[S1]: ...
456
def __getattr__(self, name: _str) -> S1: ...
457
458
def __getitem__(
tests/test_frame.py
@@ -2984,6 +2984,17 @@ def test_iloc_tuple() -> None:
2984
df = df.iloc[0:2,]
2985
2986
2987
+def test_take() -> None:
2988
+ df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
2989
+ check(assert_type(df.take([0, 1]), pd.DataFrame), pd.DataFrame)
2990
+ check(assert_type(df.take([np.int64(0), np.int64(1)]), pd.DataFrame), pd.DataFrame)
2991
+ check(assert_type(df.take(np.array([0, 1])), pd.DataFrame), pd.DataFrame)
2992
+ check(assert_type(df.take([0, 1], "index"), pd.DataFrame), pd.DataFrame)
2993
+ check(assert_type(df.take([0, 1], 0), pd.DataFrame), pd.DataFrame)
2994
+ check(assert_type(df.take([0, 1], "columns"), pd.DataFrame), pd.DataFrame)
2995
+ check(assert_type(df.take([0, 1], 1), pd.DataFrame), pd.DataFrame)
2996
+
2997
2998
def test_set_columns() -> None:
2999
# GH 73
3000
df = pd.DataFrame({"a": [1, 2, 3], "b": [0.0, 1, 1]})
tests/test_series.py
@@ -1715,6 +1715,16 @@ def test_iloc_getitem_ndarray() -> None:
1715
check(assert_type(values_s.iloc[indices_u64], pd.Series), pd.Series)
1716
1717
1718
1719
+ s = pd.Series(np.arange(10), name="a")
1720
+ check(assert_type(s.take([0, 1]), pd.Series), pd.Series)
1721
+ check(
1722
+ assert_type(s.take([np.int64(0), np.int64(1)]), pd.Series),
1723
+ pd.Series,
1724
+ )
1725
+ check(assert_type(s.take(np.array([0, 1])), pd.Series), pd.Series)
1726
1727
1728
def test_iloc_setitem_ndarray() -> None:
1729
# GH 85
1730
# GH 86
0 commit comments