问题
I have a dictionary that has dataframes in values, something like this -
mydict = {'demand': demand_df, 'supply':supply_df, 'prod': prod_df}
Then I am using pandasql
module to execute a simple query.
query = "SELECT * FROM mydict['demand']"
print(ps.sqldf(query))
This is giving out an error -
AttributeError: 'dict' object has no attribute 'index'
However, if I add an extra step, it does work -
demand = mydict['demand']
query = "SELECT * FROM demand"
print(ps.sqldf(query))
How do I work with the first option above?
来源:https://stackoverflow.com/questions/51686216/using-dictionary-values-in-pandasql