I have a class where the only input is a dataframe. The first function within the class adds columns to the dataframe to create a new dataframe. I want subsequent functions within the class to use the new dataframe.
class House:
def __init__(self, df):
self.df = df
def df_manip(self):
# add additional columns to the dataframe
return new_df
def function1(self):
answer = new_df.column3.sum()
return answer
df = pd.read_csv('data.csv')
house_1 = House(df)
print(house_1.function1())
df_manipaddself.df = new_df- then useself.dfthroughout.