1

我正在尝试从数据库中查询,并且尝试查找格式化 SoQL 字符串的正确方法,但我失败了。我尝试以下方法:

from __future__ import division, print_function
from sodapy import Socrata
import pandas as pd
import numpy as np


client = Socrata("data.cityofchicago.org", None)

df = client.get("kkgn-a2j4", query="WHERE traffic > -1")

并收到一个错误信息Could not parse SoQL query "WHERE traffic > -1" at line 1 character 1。但是,如果我执行以下操作,它会起作用:

from __future__ import division, print_function
from sodapy import Socrata
import pandas as pd
import numpy as np


client = Socrata("data.cityofchicago.org", None)

df = client.get("kkgn-a2j4", where="traffic > -1")

但我想知道如何让查询参数起作用,以便我可以使用更复杂的查询。具体来说,我想尝试查询 whentraffic > -1BETWEEN '2013-01-19T23:50:32.000' AND '2014-12-14T23:50:32.000'.

4

1 回答 1

2

您可以使用 sodapywhere参数($where在 SoQl 中)来组合多个过滤器,只需使用AND来组合它们:

traffic > -1 AND last_update BETWEEN '2013-01-19T23:50:32.000' AND '2014-12-14T23:50:32.000'

于 2017-04-11T16:28:32.480 回答