I have function that performs standard preprocessing on each dataframe. I am passing 4 dataframes to that function as a list through for loop. But the changes performed in the function are not reflected back in actual dataframe. Why?
My Code :
def merge_preprp(x):
x[x.columns[0]] = x[x.columns[0]].astype(str)
x[x.columns[0]]= x[x.columns[0]].str.extract('(\d+)')
x = x[pd.notnull(x[x.columns[0]])]
x = x[x[x.columns[0]].apply(lambda x: x.isnumeric())]
x[x.columns[0]] = x[x.columns[0]].astype(int)
x.sort_values(x.columns[0], inplace = True)
x.drop_duplicates(subset = x.columns[0], keep = 'last',inplace = True)
return x
# dataframes A, B, C
list1 = [A,B,C]
for i in list1:
i =merge_preprp(i)