I have a dictionary that has Pandas dataframes as values. I want to get a new DataFrame
joining all the dataframes contained in the dictionary. The problem is that I need to create a new column in which each row has the value of the key of that DataFrame
in the dictionary.
I think it will be better understood with an example:
We have the following dictionary, which we will call diccionario
:
{0: count eclipse_id
7 19 10453
56 12 11305
48 11 11305
1: count eclipse_id
13 9 11305
9 5 11339}
The goal is to transform it into:
count item_id user_id
19 10453 0
12 11305 0
11 11305 0
9 11305 1
5 11339 1
As you can see, the value of each row in the column user_id
corresponds to the key that its respective DataFrame had in the original dictionary.