ENH/PERF: copy=True keyword in methods where copy=False can improve perf · Issue #48141 · pandas-dev/pandas (original) (raw)
xref #48117, #47993, #48043, #47934, #47932
We have a number of methods that currently make copies but don't have to, mainly methods that revolve around index/columns while leaving the data untouched. e.g. DataFrame.droplevel
. By adding a keyword copy=True
to these methods, we give users the choice to avoid making a copy by setting copy=False
, thereby improving performance.
@jorisvandenbossche makes a reasonable point #48117 (review) that adding this may interact with potential copy/view changes in upcoming versions.
Besides droplevel
and drop
, for which PRs are already open, the other methods I'm looking at are reset_index
, replace
, and fillna
(there may be others I haven't found). In all three of those cases, the idea would be to add copy and deprecate inplace (xref #16529).