У меня есть фрейм данных pd, который выглядит так (Ticker
- мой индекс):

Я хочу рассчитать среднюю цену для каждого запас, так что мой окончательный результат выглядит так:

Вот мой код:
average_price_output = []
for ticker in tickers:
data[ticker] = data.loc[ticker]
average_price = data.loc[ticker]['PX_LAST'].mean()
average_price_output.append(round(float(average_price[-1:]), 1))
model_results = pd.DataFrame(list(zip(average_price_output)),
columns =['Average Price']).set_index([tickers])
И ошибка I ' m получается:
ValueError: cannot reindex from a duplicate axis.
Кажется, что проблемная строка: data[ticker] = data.loc[ticker]
Что я делаю не так? Заранее спасибо.