Using dictionary values in pandasql

房东的猫 提交于 2019-12-24 00:48:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!