Skip to content
Advertisement

Pandas split list upon DataFrame creation

I have a JSON file coming in, which I am doing some operations/trimming on.

The result looks like this:

JavaScript

When applying df = pd.DataFrame(user, index=[0]) I get the following Dataframe:

JavaScript

When applying df = pd.DataFrame(user) I get:

JavaScript

I am aware, as to why that happens, however none is what I want.

I’d like the following:

JavaScript

However I am not sure what the best way is to split the position parameter.

Advertisement

Answer

You can just pandas.json_normalize , then later rename the columns:

JavaScript

OUTPUT

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement