Search code examples
blaze

How to filter the record in blaze where id is equal to the specified id?


I am using blaze for querying data from csv and json. I just need to query a record where id is equal to the specified id? Is it possible.

city = city[city.ID = 1]

While trying to execute the above code it shows SyntaxError: invalid syntax


Solution

  • That works, but in your case you'd need to have a field named ID, it's not a magical field. The following works, but only because there's a column explicitly named id in accounts.csv:

    from blaze import Data
    from blaze.utils import example
    
    accounts = Data(example('accounts.csv')
    accounts[accounts.id == 2]
    #    id  name  balance
    # 1   2   Bob      200