I have a pandas dataframe that looks like this...
index | my_column |
---|---|
0 | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 |
What I need to do is conditionally assign values to 'my_column' depending on the index. The first three rows should have the values 'dog', 'cat', 'bird'. Then, the next three rows should also have 'dog', 'cat', 'bird'. That pattern should apply until the end of the dataset.
index | my_column |
---|---|
0 | dog |
1 | cat |
2 | bird |
3 | dog |
4 | cat |
5 | bird |
6 | dog |
I've tried the following code to no avail.
for index, row in df.iterrows():
counter=3
my_column='dog'
if counter>3
break
else
counter+=1
my_column='cat'
counter+=1
if counter>3
break
else
counter+=1
my_column='bird'
if counter>3
break