I have a pandas df with a column (let's say col3) containing a number. These numbers are used in multiple rows and I want to run a function for rows of each number separatly.
So I wrote each number once into an array like this:
l = df.col3.unique()
Then a for loop is used to run a function for each number:
for i in l:
a,b = func(df[df.col3 == i])
So the function gets rows where col3 contains the value of i of each run. The function returns two data frames (a and b in this case). I need these two returned data frames of each run.
I want to be able to identify them properly. For that I would like to save returned data frames within the loop like this:
First run: a123, b123 Second run a456, b456 Third run: a789, b789
Means the name of the dataframe contains the current value of i.
I already read I should not use global variables for dynamic variable names but do not know how to realize this instead.
Thank you :)