import pandas as pd
class MyClass():
def __init__(self, df):
self.df = df
def edit(self):
self.df = self.df[~self.df['numbers'].isin([2,4,6,8,10])]
df = pd.DataFrame([1,2,3,4,5,6,7,8,9,10], columns=['numbers'])
obj = MyClass(df).edit()
print df
I am expecting print df
to print the dataframe which has been reassigned after the filteration function.
But this stil prints the dataframe which is before the edit
function modify it.
How can my outer variable still track the changes happend to the df
inside class