So I was working with Pandas and I recently came across the inplace argument, which changes the original variable without having to reassign it.
Example : df.dropna(inplace=True)
instead of df = df.dropna()
I want to apply the same mechanism but for custom functions. However only the list
type is natively supported
def append(x, element):
x.append(element)
x = [1, 2, 3, 4]
append(x, 5)
x
[1, 2, 3, 4, 5]
if I try this with a different type, it does not work
def to_lower(text):
text.lower()
text = 'Hello World'
to_lower(text)
text
'Hello World'
Does anyone know how Pandas inplace
does the job ?