0

I have a dictionary that looks like the following

output = {year:{month:{day:{'parameter1':[1x24 ndarray], parameter2:[1x24 ndarray].....}}}}

Each element in the ndarray is a value for an hour of the day.

I need to translate it to a dataframe which looks like the following:

Yr Mth Day Hour parm1 parm2 .....
1   1   1   1   2500    0   0   1679.389313
1   1   1   2   2500    0   0   1323.25619
1   1   1   3   2500    0   0   2500
1   1   1   4   2500    0   0   2369.474574
1   1   1   5   2500    0   0   2433.861107
1   1   1   6   2500    0   0   2433.911271
1   1   1   7   2500    0   0   2432.065217
1   1   1   8   2500    0   0   2500
1   1   1   9   2500    0   0   2460.31746
1   1   1   10  2500    0   0   2500
1   1   1   11  2500    0   0   2500
1   1   1   12  2500    0   0   2468.193384
1   1   1   13  2500    0   0   2451.68308
1   1   1   14  2500    0   0   2443.112846
1   1   1   15  2500    0   0   2438.664174
1   1   1   16  2500    0   0   2145.637204
1   1   1   17  2500    0   0   2392.41198
1   1   1   18  2500    0   0   2459.23913
1   1   1   19  2500    0   0   2500
1   1   1   20  2500    0   0   2500
1   1   1   21  2500    0   0   2500
1   1   1   22  2500    0   0   2468.193384
1   1   1   23  2500    0   0   2451.68308
1   1   1   24  2500    0   0   980.3921569
1   1   2   1   2500    0   0   1679.389313
1   1   2   2   2500    0   0   2042.227531
1   1   2   3   2500    0   0   1716.640777
1   1   2   4   2500    0   0   2433.861925

Is there an easy way to do this with pandas.

I have tried the pd.DataFrame(dict) and some other variations of it by creating individual dataframes for each day and appending them. Is there a quicker or an easier way to do this.

James
  • 32,991
  • 4
  • 47
  • 70
  • Welcome to Stackoverflow! please read [here how to ask a good question](https://stackoverflow.com/help/how-to-ask) also provide the code of your tries, so we can help you to solve the problem. – Carlo Zanocco Feb 06 '20 at 22:16
  • Please share enough code/data for us to be able to write and test solutions. – AMC Feb 06 '20 at 23:38
  • Does this answer your question? [Construct pandas DataFrame from items in nested dictionary](https://stackoverflow.com/questions/13575090/construct-pandas-dataframe-from-items-in-nested-dictionary) – Carlo Zanocco Feb 07 '20 at 07:27

0 Answers0