price
price date fruit
0 0.83 2010-01-04 banana
1 0.05 2010-01-04 appple
Как вы можете использовать формулу oop для исправления элементов в списке? Моя цель:
price = price.set_index('date').dropna(how='all').resample('W').last()```
keep if fruit == banana
drop the column fruit
perform calculations
repeat for all other fruits in the dataset price
Я пробовал
fruits = ['apple', 'banana', 'pair']
listxx = [(price, "price")]
for fruit in fruits:
for i, (x, y) in enumerate(listxx):
listxx[i] = x['fruit'] == fruit
listxx[i] = x.set_index('date').dropna(how='all').resample('W').last()
listxx[i].drop(listxx[i].columns[fruit], axis=1, inplace=True)
perform calculations