I am trying to create a panel object from stacked panel data. See code below. I have a set of 8000 stocks and I try to create the panel such that the stocks are on items axis. Here is my code:
import pandas as pd
data = pd.read_csv('C:Stocks.csv', index_col='date')
identifier = pd.unique(data['CUSIP'])
dict_dfStocks={}
for k in identifier :
print(k)
dict_dfStocks[k]= data[data.CUSIP==k]
pd.Panel.from_dict(dict_dfStocks)
However, I get the following error:
"ValueError: cannot reindex from a duplicate axis"
Thank you!