I have several dictionaries that I would like to merge into a pd.DataFrame
. In order to be able to do that, all the dictionaries need to have a dimension of 1. How can I reduce the dimension of the following dictionary to 1 but so that it remains a dictionary? In cases where there are multiple entries for a dictionary item, it should simply be joined. So myFunds
should become '2.0 0.0'
h = {
'gameStage': 'PreFlop',
'losses': 0,
'myFunds': [2.0, '0.0'],
'myLastBet': 0,
'peviousRoundCards': ['2S', 'QS'],
'previousCards': ['2S', 'QS'],
'previousPot': 0.03,
'wins': 0
}
To be more precise what my problem is: I want to save all properties of an object in a DataFrame
. For that I do vars(Object)
which gives me a dictionary, but not all of the entries have the same dimension, so I can't do DataFrame(vars(Object))
because I get an error. That's why I need to first convert vars(Object)
into a one dimensional dictionary. But it needs to remain a Dictionary, otherwise I can't convert it into a DataFrame
.