0

This is the flattened version of the column. I still need the keys as column titles for the dataframe and the values as values for the corresponding column.

reaction
{ "veddra_term_code": "99026", "veddra_version": "3", "veddra_term_name": "Tablets, Abnormal" }

I want my data to look like this so I can add it to the dataframe.

veddra_term_code    veddra_version  veddra_term_name
99026                       3            'Tablets, Abnormal'
Nick ODell
  • 15,465
  • 3
  • 32
  • 66
Andrea
  • 57
  • 1
  • 7
  • Very similar to https://stackoverflow.com/questions/38231591/splitting-dictionary-list-inside-a-pandas-column-into-separate-columns?noredirect=1&lq=1 – Nick ODell Jan 16 '21 at 06:45

1 Answers1

0

Use f-strings. Theyre made for creating strings formatted like you want:

d = { "veddra_term_code": "99026", "veddra_version": "3", "veddra_term_name": "Tablets, Abnormal" }
s = f'veddra_term_code veddra_version veddra_term_name {d["veddra_term_code"]} {d["veddra_version"]} \'{d["veddra_term_name"]}\''
print(s) # prints veddra_term_code veddra_version veddra_term_name 99026 3 'Tablets, Abnormal'
ICW
  • 4,875
  • 5
  • 27
  • 33