For sqldf method of pandasql package, there is a "session/environment variables", could be locals() or globals(), could anyone let me know what it is for? And any document reference when should we use locals(), and when should we use globals()?
https://github.com/yhat/pandasql/
Here is my code and wondering what things pandansql is looking for thorough locals()? And locals() means namespace inside method select_first_50?
def select_first_50(filename):
students = pandas.read_csv(filename)
students.rename(columns = lambda x: x.replace(' ', '_').lower(), inplace=True)
q = "select major, gender from studentstable limit 50"
#Execute your SQL command against the pandas frame
results = pandasql.sqldf(q.lower(), locals())
return results