noodle
noodle

Reputation: 1

Python Socrata API - Unable to manipulate Floating Timestamps

I'm new to python programing so apologies for potential newbie questions. I'm trying to filter "Floating Timestamp Datatypes" within the Marin County Socrata API. I'm using the basic outline they provided here: https://dev.socrata.com/foundry/data.marincounty.org/mkbn-caye

    # pip install pandas
    # pip install sodapy

    import pandas as pd
    from sodapy import Socrata

    # Unauthenticated client only works with public data sets. Note 'None'
    # in place of application token, and no username or password:
    client = Socrata("data.marincounty.org", None)

    # Example authenticated client (needed for non-public datasets):
    # client = Socrata(data.marincounty.org,
    #                  MyAppToken,
    #                  userame="[email protected]",
    #                  password="AFakePassword")

    # First 2000 results, returned as JSON from API / converted to Python list of
    # dictionaries by sodapy.
    results = client.get("mkbn-caye", limit=2000)

    # Convert to pandas DataFrame
    results_df = pd.DataFrame.from_records(results)

I am trying to ping the database to get information about permit applications that have been submitted within the last week (have a "received_date") but have not yet had a permit issued (do not have a "issued_date"). I would like to run the code every week to get updates. I started working with the below code, and it does work:

    import pandas as pd
    from sodapy import Socrata
    client = Socrata("data.marincounty.org",*MyAppToken*)
    results = client.get("mkbn-caye", received_date = '2019-09-25T13:50:27.000')
    results_df = pd.DataFrame.from_records(results)
    print(results_df) # prints the DataFrame

However if I make one slight change from the "=" operator to the ">" operator:

results = client.get("mkbn-caye", received_date > '2019-09-25T13:50:27.000')

I get the following error code:

results = client.get("mkbn-caye", received_date > '2019-09-25T13:50:27.000')

NameError: name 'received_date' is not defined

How is the 'received_date' not defined when it worked fine with the "=" operator?

Like I mentioned before, eventually, I'd like to have something along the following work but making small baby steps

received_date > 'One Week Ago'\    #The date would be 1 week ago
issued_date IS NULL                # This doesn't work either. I want entries that have no "issued_date" field yet

I am trying to use the guidelines here: https://dev.socrata.com/foundry/data.marincounty.org/mkbn-caye to work with the "Floating Timestamp DataTypes". Any suggestions?

Upvotes: 0

Views: 280

Answers (1)

noodle
noodle

Reputation: 1

It was something simple. Just needed another pair of "".

results = client.get("mkbn-caye", \
                 where="received_date > '2019-09-25T13:50:27.000'")

Upvotes: 0

Related Questions