I have a code that return the max value of each column in the dataframe until now it returns a list of the correct items.
What I want is to assign each item into a variable where this variable is created inside the for loop over the list.
expected result:
- var1=item0
- var2=item1
- var3=item2
where the var is a variable created by the iteration over the list.
if i run the code below it crash and return this error:
for i, l in lgdf:
TypeError: cannot unpack non-iterable int object
code:
import pandas as pd
grouped_df=pd.crosstab(df['year_month'], df['event_type'])
lgdf = list(grouped_df.max())
i = 0
for i, l in lgdf:
var[i]=l
print(var)