lets say I have a brand of list:
cat_list = ['a', 'b', 'ab']
and I want this list to repeteadly fill a new column called category as much as my rows have.
I want the first row have 'a', the second row have 'b', and the third row have 'ab', and the cycle repeats until the last rows like the example below:
type value category
a 25 a
a 25 b
a 25 ab
b 50 a
b 50 b
b 50 ab
What I have tried so far is:
cat_list = ['a', 'b', 'ab']
df['category'] = cat_list * len(df)
but I got this kind of error
Length of values does not match length of index
how should I fix my script in order to get the desired results?
thanks.