我正在学习如何在Pandas中使用JSON文件。
可以通过以下代码行读取包含数据的公开JSON文件:
import requests
import json
url = 'https://data.seattle.gov/resource/65db-xm6k.json'
response = requests.get(url)
data_json = response.json()
如何对列上的data_json进行排序,以便进一步处理它?
答案 0 :(得分:0)
就像读取pandas
中的json文件一样简单:
import pandas as pd
df = pd.DataFrame(data_json)
df
date fremont_bridge fremont_bridge_sb fremont_bridge_nb
0 2012-10-03T00:00:00.000 13 4 9
1 2012-10-03T01:00:00.000 10 4 6
2 2012-10-03T02:00:00.000 2 1 1
3 2012-10-03T03:00:00.000 5 2 3
4 2012-10-03T04:00:00.000 7 6 1
... ... ... ... ...