What is inplace=True?

0311

inplace=True is a parameter used in various pandas methods to modify the original DataFrame or Series directly, rather than returning a new object. When you set inplace=True, the changes are applied to the original data structure, and no new object is created.

For example, when using the drop() method:

df.drop([1], inplace=True)

This will remove the row with index 1 from the original DataFrame df without creating a new DataFrame.

Similarly, for filling missing values with ffill():

df.ffill(inplace=True)

This will fill the missing values in the original DataFrame directly.

0 Comments

no data
Be the first to share your comment!