This has probably been asked before, but I can't find any post on that.
I want to create a DataFrame containing several days of pipeline output. I want to have the date as the index level 0 and the equity as the index level 1. Since the equities might change every day, I can't set the level 1 index in advance.
I would need something like this. Any suggestion?
if not 'full_data' in context:
columns = [context.output.columns.values]
multi_index = pd.MultiIndex(levels=[[],[]], labels=[[],[]])
context.full_data = pd.DataFrame(columns=columns, index=multi_index)
date = get_datetime('US/Eastern')
equity_index = context.output.index.values
context.full_data.loc[date, equity_index] = context.output.values
Right now I get the following:
KeyError: '[Equity(2 [ARNC]) Equity(24 [AAPL]) Equity(31 [ABAX]) ...,\n Equity(50758 [OKTA]) Equity(50763 [SNDR]) Equity(50782 [UPL])] not in index'