Skip to content

Commit 948bf6d

Browse files
committed
DOC: remove inplace usage from docstring examples
1 parent 10c51ba commit 948bf6d

File tree

4 files changed

+2
-76
lines changed

4 files changed

+2
-76
lines changed

pandas/core/arrays/categorical.py

-7
Original file line numberDiff line numberDiff line change
@@ -1673,13 +1673,6 @@ def sort_values(
16731673
[5, 2, 2, 1, 1]
16741674
Categories (3, int64): [1, 2, 5]
16751675
1676-
Inplace sorting can be done as well:
1677-
1678-
>>> c.sort_values(inplace=True)
1679-
>>> c
1680-
[1, 1, 2, 2, 5]
1681-
Categories (3, int64): [1, 2, 5]
1682-
>>>
16831676
>>> c = pd.Categorical([1, 2, 2, 1, 5])
16841677
16851678
'sort_values' behaviour with NaNs. Note that 'na_position'

pandas/core/frame.py

-18
Original file line numberDiff line numberDiff line change
@@ -4512,17 +4512,6 @@ def eval(self, expr: str, *, inplace: bool = False, **kwargs) -> Any | None:
45124512
3 4 4
45134513
4 5 2
45144514
4515-
Use ``inplace=True`` to modify the original DataFrame.
4516-
4517-
>>> df.eval('C = A + B', inplace=True)
4518-
>>> df
4519-
A B C
4520-
0 1 10 11
4521-
1 2 8 10
4522-
2 3 6 9
4523-
3 4 4 8
4524-
4 5 2 7
4525-
45264515
Multiple columns can be assigned to using multi-line expressions:
45274516
45284517
>>> df.eval(
@@ -6372,13 +6361,6 @@ def dropna(
63726361
name toy born
63736362
1 Batman Batmobile 1940-04-25
63746363
2 Catwoman Bullwhip NaT
6375-
6376-
Keep the DataFrame with valid entries in the same variable.
6377-
6378-
>>> df.dropna(inplace=True)
6379-
>>> df
6380-
name toy born
6381-
1 Batman Batmobile 1940-04-25
63826364
"""
63836365
if (how is not no_default) and (thresh is not no_default):
63846366
raise TypeError(

pandas/core/indexes/base.py

-7
Original file line numberDiff line numberDiff line change
@@ -1745,13 +1745,6 @@ def set_names(
17451745
( 'cobra', 2018),
17461746
( 'cobra', 2019)],
17471747
)
1748-
>>> idx.set_names(['kind', 'year'], inplace=True)
1749-
>>> idx
1750-
MultiIndex([('python', 2018),
1751-
('python', 2019),
1752-
( 'cobra', 2018),
1753-
( 'cobra', 2019)],
1754-
names=['kind', 'year'])
17551748
>>> idx.set_names('species', level=0)
17561749
MultiIndex([('python', 2018),
17571750
('python', 2019),

pandas/core/series.py

+2-44
Original file line numberDiff line numberDiff line change
@@ -1494,17 +1494,6 @@ def reset_index(
14941494
3 4
14951495
Name: foo, dtype: int64
14961496
1497-
To update the Series in place, without generating a new one
1498-
set `inplace` to True. Note that it also requires ``drop=True``.
1499-
1500-
>>> s.reset_index(inplace=True, drop=True)
1501-
>>> s
1502-
0 1
1503-
1 2
1504-
2 3
1505-
3 4
1506-
Name: foo, dtype: int64
1507-
15081497
The `level` parameter is interesting for Series with a multi-level
15091498
index.
15101499
@@ -2242,11 +2231,9 @@ def drop_duplicates(
22422231
Name: animal, dtype: object
22432232
22442233
The value ``False`` for parameter 'keep' discards all sets of
2245-
duplicated entries. Setting the value of 'inplace' to ``True`` performs
2246-
the operation inplace and returns ``None``.
2234+
duplicated entries.
22472235
2248-
>>> s.drop_duplicates(keep=False, inplace=True)
2249-
>>> s
2236+
>>> s.drop_duplicates(keep=False)
22502237
1 cow
22512238
3 beetle
22522239
5 hippo
@@ -3490,17 +3477,6 @@ def sort_values(
34903477
0 NaN
34913478
dtype: float64
34923479
3493-
Sort values inplace
3494-
3495-
>>> s.sort_values(ascending=False, inplace=True)
3496-
>>> s
3497-
3 10.0
3498-
4 5.0
3499-
2 3.0
3500-
1 1.0
3501-
0 NaN
3502-
dtype: float64
3503-
35043480
Sort values putting NAs first
35053481
35063482
>>> s.sort_values(na_position='first')
@@ -3750,16 +3726,6 @@ def sort_index(
37503726
1 c
37513727
dtype: object
37523728
3753-
Sort Inplace
3754-
3755-
>>> s.sort_index(inplace=True)
3756-
>>> s
3757-
1 c
3758-
2 b
3759-
3 a
3760-
4 d
3761-
dtype: object
3762-
37633729
By default NaNs are put at the end, but use `na_position` to place
37643730
them at the beginning
37653731
@@ -5601,14 +5567,6 @@ def dropna(
56015567
1 2.0
56025568
dtype: float64
56035569
5604-
Keep the Series with valid entries in the same variable.
5605-
5606-
>>> ser.dropna(inplace=True)
5607-
>>> ser
5608-
0 1.0
5609-
1 2.0
5610-
dtype: float64
5611-
56125570
Empty strings are not considered NA values. ``None`` is considered an
56135571
NA value.
56145572

0 commit comments

Comments
 (0)