0

I want to transform distinct rows in a dataframe into columns and the values assigned to each column.

I have a pandas dataframe with this structure (coming from a json file):

    Key        Value
0   _id         1
1   type        house
2   surface     156
3   county      andr
4   _id         2
5   type        apartment
6   surface     95
7   county      sprl
8   _id         3
9   type        house
10  surface     234
11  county      ilm
..

I expect a dataframe similar to:

     _id    type      surface   county
0    1      house     156       andr
1    2      apartment 95        sprl
2    3      house     234       ilm
...
Jose I
  • 3
  • 1

1 Answers1

0
df = pd.read_json(your_json, orient='records')

This should read it in the format you want.

Danny
  • 470
  • 4
  • 14