-1

I need to convert a list of nested dictionary into Pandas Dataframe. My list is the following:

data = [{"2016-09-24":{"totalRevenue":123, "netIncome":456, "ebit":789}}, {"2015-09-24":{"totalRevenue":789, "netIncome":456, "ebit":123}}]

I want to transform the list into something like this, where the dates are column-headers and the rows are the keys to the values in the nested dicts.

The result i want as a datafram

I have tried different things, e.g.: https://www.tutorialspoint.com/python-convert-list-of-nested-dictionary-into-pandas-dataframe

But i can't seem to fix my problem.

I hope this makes sense and thanks for your help :-)

Update: I have found a solution :-)

jrn6270
  • 61
  • 11
  • 1
    Please don’t post images of the data as we can’t test them. Instead, post a sample of the data/ DataFrame and expected output directly inside a code block. This allows us to easily reproduce your problem and help you. Otherwise, the probability of you getting any answer is low. Read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – Rodalm Nov 18 '21 at 17:42
  • Thank you for your notice. I will make the changes. – jrn6270 Nov 18 '21 at 17:55
  • 1
    This is easy enough to implement, however, what have YOU tried to do? Also, have you looked for similar answered questions in SO? Because I know there are some. – Danny Varod Nov 18 '21 at 18:21

1 Answers1

0

Thanks for the notice on how to write questions @HarryPlotter and thanks for the suggested solution @Geoffrey.
I found an answer to my problem:

pd.concat([pd.DataFrame(l) for l in my_list],axis=1)
jrn6270
  • 61
  • 11