I want to refactor my code and trying to creating OOP set up for basic dataframe manipulations. This might not make sense in a larger context but I am trying to get a better grasp on OOP. I have tried a rename column function but it does not work on my created instance(m1).
df1 = pd.read_sql(query, conn)
class DataframeOperations():
def __init__(self, df):
self.df = df
def rename_column(self, name:'string', name_adj:'string'):
self.df.rename(columns = {name, name_adj}, inplace=True)
return self.df
m1 = DataframeOperations(df1)
print(type(m1))
output untill this point
<class 'main.DataframeOperations'>
m1.rename_column('col1','col2')
I get the following error when running this function:
TypeError: 'set' object is not callable