I have a pandas a dataframe which contains two columns. 1) keywords 2) TopicID.
The keyword is dictionary type. I want to normalize this dataframe in a way that each topic will repeat for each keyword and its value.
Expected Dataframe (for sample I am posting few keywords only)
I tried this code
df_final = pd.json_normalize(df.keywords.apply(json.loads))
Output of-> print (df[['TopicID','keywords']].head(2).to_dict())
{'TopicID': {0: 797, 1: 798}, 'keywords': {0: {'licence': 0.529, 'chapter': 0.462, 'explains': 0.263, 'visitor': 0.244, 'resident': 0.22, 'applying': 0.205, 'privileges': 0.199, 'graduated': 0.188, 'tests': 0.184, 'licensing': 0.18}, 1: {'emotional': 0.352, 'mental': 0.327, 'state': 0.309, 'operate': 0.295, 'drive': 0.242, 'motor': 0.227, 'ability': 0.227, 'next': 0.176, 'illness': 0.176, 'diminish': 0.176}}}

