Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I am trying to adapt the Kaggle Facial Keypoint Detection tutorial and codes to solve a a similar problem. I am trying to detect four keypoint in the human body; Left shoulder, right shoulder, nose and neck.

I used  http://labelbox.com  to label my images, but the format of the excel file I have now is two columns one with the image name and another one with a python dictionary like this:

{'LS': [{'geometry': {'x': 45, 'y': 21}}],

 'RS': [{'geometry': {'x': 28, 'y': 30}}],

 'Neck': [{'geometry': {'x': 38, 'y': 25}}],

 'Nose': [{'geometry': {'x': 50, 'y': 15}}]}

while Kaggle data set uses a column for each point component (one for x another for y for each point).

is there a good way to separate the final x and y values for each point into separate columns.

1 Answer

0 votes
by (17.6k points)

To convert the dict into right dataframe format we will use pandas.io.json.json_normalize

from pandas.io.json import json_normalize

list_main=[]

for item in data:

    temp = dict()

    temp["tag"] = item

    data[item][0].update(temp)

    list_main.append(data[item][0])

final_df = json_normalize(list_main)

  geometry.x    geometry.y  tag

0      45            21     LS

1      28            30     RS

2      38            25     Neck

3      50            15     Nose

Browse Categories

...