I am trying to create a dict from a data frame of a stock. The dict keys should be the sector and the values the corresponding tickers.
df.set_index('Sector').to_dict()['Ticker']
I have this code which works in creating some of the dictionary. The issue being it has created the right amount of keys but only one ticker to each key. I can see from the data frame that most keys should include many more tickers.
The DataFrame looks like this:
Company | Ticker | Exchange | Sector | Date added | Weighting |
---|---|---|---|---|---|
3M | MMM | NYSE | indus | 09/08/76 | 3.022 |
the desired output will be
{Indus: MMM, BA, ....,
Financials: AXP, GS,...}
for all the industry's and tickers