I found a quick and easy solution to what I wanted using json_normalize() included in pandas 1.01.

from urllib2 import Request, urlopen
import json

import pandas as pd    

path1 = '42.974049,-81.205203|42.974298,-81.195755'
request=Request('http://maps.googleapis.com/maps/api/elevation/json?locations='+path1+'&sensor=false')
response = urlopen(request)
elevations = response.read()
data = json.loads(elevations)
df = pd.json_normalize(data['results'])

This gives a nice flattened dataframe with the json data that I got from the Google Maps API.

Answer from pbreach on Stack Overflow
🌐
W3Schools
w3schools.com › python › pandas › pandas_json.asp
Pandas Read JSON
JSON is plain text, but has the format of an object, and is well known in the world of programming, including Pandas. In our examples we will be using a JSON file called 'data.json'. Open data.json. ... Tip: use to_string() to print the entire ...
Discussions

How to read Panda's DataFrames from json file?
I have a huge collection of json files containing a single panda’s dataframe each. I would like to open them in julia but I haven’t found the solution. A caveat is that the dataframes have strings as row indexes. Any help would be appreciated! More on discourse.julialang.org
🌐 discourse.julialang.org
1
0
January 30, 2023
Convert Pandas DataFrame to JSON format - Stack Overflow
I have a Pandas DataFrame with two columns – one with the filename and one with the hour in which it was generated: File Hour F1 1 F1 2 F2 1 F3 1 I am More on stackoverflow.com
🌐 stackoverflow.com
Python - How To Convert Pandas Dataframe To JSON Object? - Stack Overflow
I'm using df.to_json() to convert dataframe to json. But it gives me a json string and not an object. How can I get JSON object? Also, when I'm appending this data to an array, it adds single quote More on stackoverflow.com
🌐 stackoverflow.com
Converting a JSON file into a Pandas Dataframe
You can also try pandas.json_normalize() and play around to match your desired output More on reddit.com
🌐 r/dataengineering
17
3
July 7, 2021
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.to_json.html
pandas.DataFrame.to_json — pandas 3.0.1 documentation
orient='table' contains a ‘pandas_version’ field under ‘schema’. This stores the version of pandas used in the latest revision of the schema. Examples · >>> from json import loads, dumps >>> df = pd.DataFrame( ... [["a", "b"], ["c", "d"]], ... index=["row 1", "row 2"], ... columns=["col 1", "col 2"], ... ) >>> result = df.to_json(orient="split") >>> parsed = loads(result) >>> dumps(parsed, indent=4) {{ "columns": [ "col 1", "col 2" ], "index": [ "row 1", "row 2" ], "data": [ [ "a", "b" ], [ "c", "d" ] ] }} Encoding/decoding a Dataframe using 'records' formatted JSON.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › how-to-convert-pandas-dataframe-into-json-in-python
How to convert pandas DataFrame into JSON in Python? - GeeksforGeeks
June 12, 2025 - The orient parameter allows you to control how the DataFrame is structured in the resulting JSON. Pandas to_json() provides multiple format options through the orient parameter.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › pandas-convert-json-to-dataframe
Convert JSON to Pandas DataFrame - GeeksforGeeks
July 23, 2025 - Pandas, a powerful data manipulation library in Python, provides a convenient way to convert JSON data into a Pandas data frame. In this article, we'll explore how to convert JSON data into a Pandas DataFrame, covering various scenarios and options you might encounter along the way.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.read_json.html
pandas.read_json — pandas 3.0.1 documentation
Normalize semi-structured JSON data into a flat table. ... Specific to orient='table', if a DataFrame with a literal Index name of index gets written with to_json(), the subsequent read operation will incorrectly set the Index name to None. This is because index is also used by DataFrame.to_json() ...
Find elsewhere
🌐
Reddit
reddit.com › r/dataengineering › converting a json file into a pandas dataframe
r/dataengineering on Reddit: Converting a JSON file into a Pandas Dataframe
July 7, 2021 -

Hi All,

I am trying to learn building data pipelines. So as a hobby project, I have done some web-scraping from a football stats website and extracted some data in JSON format. However, the format is such that I am unable to convert it into a Pandas Data frame. Could someone help me with it? The data sample is as below -

[

{"player_name": ["Kylian Mbapp\u00e9", "Erling Haaland", "Harry Kane", "Jadon Sancho", "Mohamed Salah", "Romelu Lukaku", "Kevin De Bruyne", "Neymar", "Frenkie de Jong", "Bruno Fernandes", "Joshua Kimmich", "Raheem Sterling", "Marcus Rashford", "Sadio Man\u00e9", "Heung-min Son", "Jo\u00e3o F\u00e9lix", "Phil Foden", "Lautaro Mart\u00ednez", "Marcos Llorente", "Lionel Messi", "Mason Mount", "Matthijs de Ligt", "Trent Alexander-Arnold", "R\u00faben Dias", "Marquinhos"], "player_age": ["Age", "22", "20", "27", "21", "29", "28", "30", "29", "24", "26", "26", "26", "23", "29", "28", "21", "21", "23", "26", "34", "22", "21", "22", "24", "27"], "market_value": ["\u20ac160.00m", "\u20ac130.00m", "\u20ac120.00m", "\u20ac100.00m", "\u20ac100.00m", "\u20ac100.00m", "\u20ac100.00m", "\u20ac100.00m", "\u20ac90.00m", "\u20ac90.00m", "\u20ac90.00m", "\u20ac90.00m", "\u20ac85.00m", "\u20ac85.00m", "\u20ac85.00m", "\u20ac80.00m", "\u20ac80.00m", "\u20ac80.00m", "\u20ac80.00m", "\u20ac80.00m", "\u20ac75.00m", "\u20ac75.00m", "\u20ac75.00m", "\u20ac75.00m", "\u20ac75.00m"]},

{"player_name": ["Pedri", "Alphonso Davies", "Rodri", "Mikel Oyarzabal", "Kai Havertz", "Sergej Milinkovi\u0107-Savi\u0107", "Bernardo Silva", "Rapha\u00ebl Varane", "Serge Gnabry", "Leon Goretzka", "Jan Oblak", "Casemiro", "Bukayo Saka", "Fede Valverde", "Declan Rice", "Nicol\u00f2 Barella", "Kingsley Coman", "Andrew Robertson", "Jack Grealish", "Timo Werner", "Ansu Fati", "Jules Kound\u00e9", "Achraf Hakimi", "Gabriel Jesus", "Dayot Upamecano"], "player_age": ["Age", "18", "20", "25", "24", "22", "26", "26", "28", "25", "26", "28", "29", "19", "22", "22", "24", "25", "27", "25", "25", "18", "22", "22", "24", "22"], "market_value": ["\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac70.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac65.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m"]},

{"player_name": ["Federico Chiesa", "Gianluigi Donnarumma", "Alessandro Bastoni", "Wilfred Ndidi", "Jos\u00e9 Mar\u00eda Gim\u00e9nez", "Fabinho", "Milan Skriniar", "Leroy San\u00e9", "Antoine Griezmann", "Paul Pogba", "Thibaut Courtois", "Alisson", "Marc-Andr\u00e9 ter Stegen", "Koke", "Robert Lewandowski", "Eduardo Camavinga", "Jude Bellingham", "Richarlison", "Franck Kessi\u00e9", "James Maddison", "Youri Tielemans", "N'Golo Kant\u00e9", "Jo\u00e3o Cancelo", "Virgil van Dijk", "Marco Verratti"], "player_age": ["Age", "23", "22", "22", "24", "26", "27", "26", "25", "30", "28", "29", "28", "29", "29", "32", "18", "18", "24", "24", "24", "24", "30", "27", "29", "28"], "market_value": ["\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac60.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m", "\u20ac55.00m"]}]

🌐
Reddit
reddit.com › r/learnpython › pandas to json df.to_json() formatting
r/learnpython on Reddit: Pandas to JSON df.to_json() formatting
January 27, 2021 -

Suppose that I have the following dataframe:

    info     drinks reviews score menu   funfacts   
    input    1.0    1       2     4      1. funfacts, 2. fun fact, 3. fun fact

How could I transform this to the required JSON format? I tried Pandas(df.to_json) however the default formatting seems incorrect.

Snippet: `df3.to_json('File Name.json', orient='records')`

Expected output:

     {
       "info":[
          {
             "drinks":[
                "1.0"
             ],
             "reviews":[
                "1"
             ],
             "score":[
                "2"
             ],
             "menu":[
                "4"
             ],
             "funfacts":[
                "1. funfacts",
                "2. fun fact",
                "3. fun fact"
             ]
          }
       ]
    }

Current output:

    [
      {
        "drinks": "1.0",
        "reviews": "1",
        "score": "2",
        "menu": "4",
        "funfacts": "1. funfacts ,2. fun facts ,3 fun facts"
      }
    ]

Are there any arguments in pandas that I could use to get the desired format or do I need to use a different solution? Thanks

🌐
Moonbooks
en.moonbooks.org › Articles › How-to-store-a-pandas-dataframe-into-a-json-file-
How to store a pandas dataframe into a json file ?
Tags: Python; Pandas; DataFrame; JSON; Examples of how to store (convert/transform) a pandas dataframe into a json file · Table of contents · Create a dataframe with pandas · Convert the dataframe into a json string representation · Convert the string to a dictionary ·
🌐
Medium
medium.com › @machinelearningpy123 › pandas-dataframe-to-json-8-code-examples-8f76a41599ef
Pandas DataFrame to JSON [8 Code Examples] | by Zeeshan Ali | Medium
November 19, 2023 - In the world of data manipulation and analysis, Pandas is a powerhouse library in Python. It provides easy-to-use data structures and functions to work with structured data. One common task is converting a Python Pandas DataFrame to JSON format.
🌐
w3resource
w3resource.com › pandas › dataframe › pandas-dataframe-to_json.html
pandas-dataframe-to_json
import numpy as np import pandas as pd · In [2]: df = pd.DataFrame([['p', 'q'], ['r', 's']], index=['row 1', 'row 2'], columns=['c1', 'c2']) df.to_json(orient='split') Out[2]: '{"columns":["c1","c2"],"index":["row 1","row 2"],"data":[["p","q"],["r","s"]]}' Encoding/decoding a Dataframe using 'records' formatted JSON: In [3]: df.to_json(orient='records') Out[3]: '[{"c1":"p","c2":"q"},{"c1":"r","c2":"s"}]' Encoding/decoding a Dataframe using 'index' formatted JSON: In [4]: df.to_json(orient='index') Out[4]: '{"row 1":{"c1":"p","c2":"q"},"row 2":{"c1":"r","c2":"s"}}' Encoding/decoding a Datafram
🌐
Swdevnotes
swdevnotes.com › python › 2022 › extract-data-from-json-in-pandas-dataframe
Extract data from JSON in Pandas Dataframe | Software Development Notes
July 24, 2022 - Here are a number of ways to extract all the elements from json objects at once and append the data as columns to the Dataframe. The first loads the JSON data twice once for values and once for keys, this could be improved by defining a function to load the json and return a pandas series.
🌐
Medium
medium.com › @amit25173 › how-to-load-json-files-in-pandas-de7c66d75ba6
How to Load JSON Files in Pandas? | by Amit Yadav | Medium
March 6, 2025 - That’s it! Pandas can directly parse a JSON string and convert it into a DataFrame.
🌐
PyPI
pypi.org › project › pandas
pandas · PyPI
Robust I/O tools for loading data from flat files (CSV and delimited), Excel files, databases, and saving/loading data from the ultrafast HDF5 format · Time series-specific functionality: date range generation and frequency conversion, moving window statistics, date shifting and lagging · The source code is currently hosted on GitHub at: https://github.com/pandas-dev/pandas
      » pip install pandas
    
Published   Feb 17, 2026
Version   3.0.1
🌐
datagy
datagy.io › home › pandas tutorials › pandas reading & writing data › convert a pandas dataframe to json
Convert a Pandas DataFrame to JSON • datagy
December 15, 2022 - In this tutorial, you’ll learn how to convert a Pandas DataFrame to a JSON object and file using Python. Most programming languages can read, parse, and work with JSON. Because of this, knowing how to convert a Pandas DataFrame to JSON is an important skill. Pandas provides a lot of flexibility ...