We have had some questions regarding the structure of the pandas.DataFrame that we get from a History call:

df = self.History(["SPY","TQQQ"], 1000)

df is a multi-index pandas.DataFrame where the symbols ("SPY" and "TQQQ") are index 0 and date/time is index 1:


For some applications, it is more convenient to have the symbols in the columns:

# Select the closing prices
prices = hist.close

# Get data frame for each symbol
spy = prices.loc['SPY']
tqqq = prices.loc['TQQQ']

# Concat the data frames and define the columns
prices = pd.concat([spy,tqqq],axis = 1)
prices.columns = self.stocks

Please checkout a working example below where we can find the application that needs a different data frame structure. 

Thanks to Yan Xiaowei for the proposed solution.
We welcome alternative solutions.