Skip to content

Commit 04ad61e

Browse files
update abstract
1 parent 733e06a commit 04ad61e

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

web/pandas/pdeps/0008-inplace-methods-in-pandas.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,18 @@
1212

1313
This PDEP proposes that:
1414

15-
- The ``inplace`` parameter will be removed from any methods that never can be done inplace
16-
- The ``inplace`` parameter will also be removed from any methods that modify the shape of a pandas object's values or
17-
don't modify the internal values of a pandas object at all.
18-
- In contrast, the ``inplace`` parameter will be kept for any methods that only modify the underlying data of a pandas
19-
object.
20-
- For example, the ``fillna`` method would retain its ``inplace`` keyword, while ``dropna`` (potentially shrinks the
21-
length of a ``DataFrame``/``Series``) and ``rename`` (alters labels not values) would lose their ``inplace``
22-
keywords
23-
- For those methods, since Copy-on-Write behavior will lazily copy if the result is unchanged, users should reassign
24-
to the same variable to imitate behavior of the ``inplace`` keyword.
25-
e.g. ``df = df.dropna()`` for a DataFrame with no null values.
26-
- The ``copy`` parameter will also be removed, except in constructors and in functions/methods that convert array-likes
27-
to pandas objects (e.g. the ``pandas.array`` function) and functions/methods that export pandas objects to other data
28-
types (e.g. ``DataFrame/Series.to_numpy`` method).
29-
- Open Questions
30-
(These questions are deferred to a later revision, and will not affect the acceptance process of this PDEP.)
31-
- Should ``inplace=True`` return the original pandas object that was operated inplace on?
32-
- What should happen when ``inplace=True`` but the original pandas object cannot be operated inplace on because it
33-
shares its values with another pandas object?
15+
- The ``inplace`` parameter will be removed from any method which can never update the
16+
underlying values of a pandas object inplace or which alters the shape of the object,
17+
and where the `inplace=True` option is only syntactic sugar for reassigning the result
18+
to the calling DataFrame/Series.
19+
- As a consequence, the `inplace` parameter is only kept for those methods that can
20+
modify the underlying values of a pandas object inplace, such as `fillna` or `replace`.
21+
- With the introduction of Copy-on-Write ([PDEP-7](^1)), users don't need the `inplace`
22+
keyword to avoid a copy of the data.
23+
- For those methods that will keep the `inplace=True` option:
24+
- the method will do an attempt to do the operation inplace but still silently copy
25+
when needed (for Copy-on-Write), i.e. there is no guarantee it is actually done inplace.
26+
- the method will return the calling object (`self`), instead of the current `None`.
3427

3528
## Motivation and Scope
3629

@@ -433,7 +426,7 @@ be the default with Copy-on-Write).
433426

434427
## References
435428

436-
[^1]: [Copy on Write Specification](https://docs.google.com/document/d/1ZCQ9mx3LBMy-nhwRl33_jgcvWo9IWdEfxDNQ2thyTb0/edit#heading=h.iexejdstiz8u)
429+
[^1]: [Copy on Write Specification](https://pandas.pydata.org/pdeps/0007-copy-on-write.html)
437430
[^2]: <https://github.com/pandas-dev/pandas/issues/48141>
438431
[^3]: <https://github.com/pandas-dev/pandas/issues/16529>
439432
[^4]: <https://github.com/pandas-dev/pandas/issues/50535>

0 commit comments

Comments
 (0)