将 sql 查询输出隐藏到 python 中的 json
covert sql query output to json in python
我希望图表 js 使用查询的输出。
他们需要 json/array 格式的值和标签。
我是 python 和 pandas 的新手。
我的代码 -
import pandasql as pdsql
str="""select DISTINCT File_type,count(File_type) as files from final_df where Search_String='amy' group by File_type """
result=pdsql.sqldf(str,locals())
要转换成json格式的结果。
任何帮助将不胜感激。
解决了。非常容易和简单我的坏。
data_values=结果["xxxfieldxxx"].tolist()
data_labels=结果["xxxfieldxxx"].tolist()
我希望图表 js 使用查询的输出。 他们需要 json/array 格式的值和标签。 我是 python 和 pandas 的新手。 我的代码 -
import pandasql as pdsql
str="""select DISTINCT File_type,count(File_type) as files from final_df where Search_String='amy' group by File_type """
result=pdsql.sqldf(str,locals())
要转换成json格式的结果。 任何帮助将不胜感激。
解决了。非常容易和简单我的坏。 data_values=结果["xxxfieldxxx"].tolist() data_labels=结果["xxxfieldxxx"].tolist()