I have a dataframe df that loads data from a database. Most of the columns are json strings while some are even list of jsons. For example:
df
id
create a custom function to flatten columnB then use pd.concat
columnB
pd.concat
def flatten(js): return pd.DataFrame(js).set_index('pos').squeeze() pd.concat([df.drop(['columnA', 'columnB'], axis=1), df.columnA.apply(pd.Series), df.columnB.apply(flatten)], axis=1)