json - 在 pandas 中读取请求的 JSON 文件
问题描述
我正在学习如何在 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 进行排序,以便进一步处理它?
解决方案
就像读取 json 文件一样简单pandas
:
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
... ... ... ... ...
推荐阅读
- javascript - 如何在文本图像周围绘制轮廓
- python - 在 Python 中处理没有 Scrapy/Selenium/Spynner 的无限滚动
- python - 如何在numpy数组中获取“对角线”以下元素的索引
- nginx - Nginx 代理 - proxy_set_header - 来自 site.conf 的自定义标头(用于 Varnish 缓存)
- javascript - 轮播 onmouseover 和 onmouseout 不起作用
- python - python中这个递归函数的时间复杂度是多少?
- c# - 在 Monogame 中加载没有内容管道的 .FBX 文件
- internationalization - 在页面级组件上声明 namespacesRequired 数组
- javascript - 如何将一组对象组合成数组
- javascript - Discord 机器人角色问题编码