I have a nested dictionary. This is some Nasdaq data. Like this:
{'CLSN':
Date Open High Low Close Volume Adj Close
2015-12-31 1.92 1.99 1.87 1.92 79600 1.92
2016-01-04 1.93 1.99 1.87 1.93 39700 1.93
2016-01-05 1.89 1.94 1.85 1.90 50200 1.90,
'CCC':
Date Open High Low Close Volume Adj Close
2015-12-31 17.270000 17.389999 17.120001 17.250000 177200 16.965361
2016-01-04 17.000000 17.219999 16.600000 17.180000 371600 16.896516
2016-01-05 17.190001 17.530001 17.059999 17.450001 417500 17.162061,
}
To help you understand, this is the key followed by the values , and the values are the dataframe
Before asking, I tried the path pd.Panel(nas)['CLSN'], so I'm sure its value is a dataframe. But the way pd.Panel(nas).to_frame().reset_index()doesn’t help me at all! It displays an empty data block with thousands of columns that are populated with the stock name.
Now this is bothering, I want the dataframe to look like this:
index Date Open High Low Close Volume Adj Close CLSN 2015-12-31 1.92 1.99 1.87 1.92 79600.0 1.92
CLSN 2016-01-01 NaN NaN NaN NaN NaN NaN
ClSN 2016-01-04 1.93 1.99 1.87 1.93 39700.0 1.93
CCC 2015-12-31 17.270000 17.389999 17.120001 17.250000 177200.0 16.965361
CCC 2016-01-04 17.000000 17.219999 16.600000 17.180000 371600.0 16.896516
CCC 2016-01-05 17.190001 17.530001 17.059999 17.450001 417500.0 17.162061
Of course, I can use a loop forto get each frame of stock data, but it kills me to join everyone.
Do you have a better idea? Extremely want to know!
MaxU:
print(nas['CLSN'].head()) :
Open High Low Close Volume Adj Close
Date
2015-12-31 1.92 1.99 1.87 1.92 79600 1.92
2016-01-04 1.93 1.99 1.87 1.93 39700 1.93
2016-01-05 1.89 1.94 1.85 1.90 50200 1.90
2016-01-06 1.86 1.89 1.77 1.78 62100 1.78
2016-01-07 1.75 1.80 1.75 1.77 117000 1.77