Reputation: 366
I have a dictionary comprised of one key and multiple values.
dict = {'key1':['value1','value2']}
I would to take this dictionary and turn it into a pandas dataframe in the following form:
column1 column2
key1 value1
key1 value2
Where for every value, key is indicated.
Thank you!
Upvotes: 2
Views: 1266
Reputation: 153460
Try:
dct = {'key1':['value1','value2']}
pd.DataFrame(dct).melt()
Output:
variable value
0 key1 value1
1 key1 value2
Upvotes: 3