【发布时间】:2020-11-13 15:21:59
【问题描述】:
我正在处理来自 get API 请求的响应 json 文件。我已经能够弄清楚如何展平响应,并且我想通过包含 pdf 文件扩展名的记录过滤相关的数据帧,我将使用这些文件扩展名来检索感兴趣的文件。 这是代码:
from flatten_json import flatten
import requests
import pandas as pd
import re
payload= {"chamber_type":"committee","chamber":"dail","date_start":"2018-01-01", "date_end":"2018-12-31", "limit":"1000"}
test = requests.get("https://api.oireachtas.ie/v1/debates", params=payload)
text = test.content.decode("utf-8")
print(text)
test.json()
test1=flatten(test.json())
df = pd.Series(test1).to_frame()
df[["pdf"]] = df[df.index.isin(["uri_pdf"])]
我尝试使用相同的表达式过滤索引,但结果为空 df。
isin 在哪里不工作?
【问题讨论】:
标签: python python-3.x pandas filtering isin