'Removing header from json and leave json array

I have a json file in the form

{"total_rows":1000,"rows":[{data},{data},{data}]} 

and I just want

[{data},{data},{data}]

I know pandas has desired output to dataframe like:

import pandas as pd
file_reading = json.loads(open(url).read())
df = pd.DataFrame.from_dict(file_reading['rows'])
print(df)

But I am hoping for a way to do this outputting to json array and its a big dataset so I dont want to loop



Solution 1:[1]

You opened a file without closing it. There's nothing fancy needed, the JSON just translate into a dictionary in Python:

with open(url) as fp:
    file_reading = json.load(fp)

df = pd.DataFrame(file_reading["rows"])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Code Different