Considering the market_ticker dataframe:
import pandas as pd
import numpy as np
df = pd.DataFrame({'Ticker': ['EWZ US 05/29/20 P27', 'HSI US 12/30/20 C24800', 'TLT US 06/19/20 C225', 'EWZ US 05/29/20 P27'],
'Market': ['US NYSE', 'US NYSE', 'HK HKSE', 'US NYSE']})
df['Reduced_Ticker'] = df['Ticker'].apply(lambda a :" ".join(a.split(" ", 2)[:2]))
market_ticker = df[['Market','Reduced_Ticker']].groupby(['Market']).agg(list)
market_ticker['Reduced_Ticker'] = market_ticker['Reduced_Ticker'].apply(lambda x: pd.unique(x))
market_ticker
How can I transform each item in the list of indexes into a line related to the index itself? Output expected:
Market | Reduced_Ticker
HK SE | TLT US
_________________________
US NYSE | EWZ US
| HSI US