I need to try create two loops (must be separate):
LOOP 1) for each fruit:
- keep rows if that fruit is True
- remove rows with duplicate dates (either row can be deleted)
- save the result of the above as a dataframe for each fruit
LOOP 2) for each dataframe created, graph date on fruit_score:
concat apple_score banana_score date apple banana
1 apple 0.400 0.400 2010-02-12 True False
2 banana 0.530 0.300 2010-01-12 False True
3 kiwi 0.532 0.200 2010-03-03 False False
4 bana 0.634 0.100 2010-03-03 False True
I tried:
fruits = ['apple', 'banana', 'orange']
for fruit in fruits:
selected_rows = df[df[ fruit ] == True ]
df_f'{fruit}' = selected_rows.drop_duplicates(subset='date')
for fruit in fruits:
df_f'{fruit}'.plot(x="date", y=(f'{fruit}_score'), kind="line")