My following query works and returns me a Dataframe subset containing only rows containing James's records.
pat_db.query('pat_medical_records == "James"')
However, I need to retrieve the information for thousands of patients. So I am trying to assign a variable name "a" and pass it over to the above line. Here I am getting errors.
a = James
pat_db.query('pat_medical_records == a')
UndefinedVariableError: name 'a' is not defined
I then tried assigning "a" manually:
a = "James"
pat_db.query('pat_medical_records == a')
UndefinedVariableError: name 'a' is not defined
What am I missing?
pat_db.query('pat_medical_records == @a')should do the trick