0

My problem is quite straightforward.

I have the following json string:
myjson = '{"resolves_to": "16534af166355cda", "aliases": []}'
that I want to convert to a DataFrame using pd.read_json(myjson), but instead of returning a DataFrame with one row and two columns (resolves_to and aliases), with an empty entry in the column aliases (which is what I need), it returns an empty DataFrame.

I would like to understand why, and how to get the DataFrame I need.

Thank you in advance for your answers.

1 Answer 1

1

You need to make it a list:

myjson = '[{"resolves_to": "16534af166355cda", "aliases": []}]'
import pandas as pd
pd.read_json(myjson)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much! I also saw that there is an argument 'lines' to the function, that if set to True seems to perform the same thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.