Asked By – Aran Freel
pandas library many times there is an option to change the object inplace such as with the following statement…
df.dropna(axis='index', how='all', inplace=True)
I am curious what is being returned as well as how the object is handled when
inplace=True is passed vs. when
Are all operations modifying
inplace=True? And when
inplace=False is a new object created immediately such as
new_df = self and then
new_df is returned?
If you are trying to close a question where someone should use
inplace=True and hasn’t, consider replace() method not working on Pandas DataFrame instead.
Now we will see solution for issue: Understanding inplace=True in pandas
inplace=True is passed, the data is renamed in place (it returns nothing), so you’d use:
inplace=False is passed (this is the default value, so isn’t necessary), performs the operation and returns a copy of the object, so you’d use:
df = df.an_operation(inplace=False)