How to split the JSON valued column

image
I want to split the json value , present in belong_to_collection and genres columns
into id and name and merge them as separated column in the dataset.
Can anyone help me by providing some code to split it .

You would have to use json.loads() function to process values from such columns into dictionaries.

No idea what “merge them as separated column” means.

You could store these IDs with names in separate dataframe and then merge() with the original dataframe.

Also note, that the values repeat in genres column (and I suspect belongs_to_collection as well). When processing this column, you would have to make sure that the IDs stay unique in the final dataframe.

I mean i want to separate the keys of the dictionary i.e id and name and make a separate column of them in my train_set

How do you want to store 2 values in one column?
Besides this wouldn’t make sense, as every movie can belong to more than one genre/collection.

This is many-to-many problem, and you can’t get what you want so easily.

The real question should be what are you trying to achieve.

This process looks stressful but I feel it might do the job.I 'll to replace the unwanted parentheses using the replace function.This should be done till you are left with the two important keywords.