When reading JSON as pandas dataframe, we sometimes get the valueerror: expected object or value. The primary reasons for this error are –

  • JSON file path is not correct.
  • Error in JSON format.

So, first of all check if your file path is correct. Pandas can accept any valid file path including the URLs like http(s), ftp, s3 etc. You can use the local paths like – file:///C:/Users/akash/Downloads/myfile.json.

import pandas as pd
data= pd.read_json('file:///C:/Users/akash/Downloads/myfile.json')

    Tweet this to help others

Learn more about read_json.

Comments

About the Author

akamit

I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles