Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将动态博克图表插入谷歌网站_Python_Pandas_Data Visualization_Bokeh_Google Sites 2016 - Fatal编程技术网

Python 将动态博克图表插入谷歌网站

Python 将动态博克图表插入谷歌网站,python,pandas,data-visualization,bokeh,google-sites-2016,Python,Pandas,Data Visualization,Bokeh,Google Sites 2016,我正在使用Python中的Bokeh库创建交互式web图表。我想将这些图表存储在谷歌网站上,以便在我的组织域内轻松访问,但我不知道如何保持实时同步 图表的数据在谷歌电子表格中。我将数据导入Pandas数据框,然后在Bokeh中创建可视化。我可以获取html输出文件并将其复制到Google站点的嵌入式小部件中,但这仍然是一个静态可视化。我希望图表在新数据添加到google工作表时刷新。这可能吗?以下是我的代码: from bokeh.plotting import figure from boke

我正在使用Python中的Bokeh库创建交互式web图表。我想将这些图表存储在谷歌网站上,以便在我的组织域内轻松访问,但我不知道如何保持实时同步

图表的数据在谷歌电子表格中。我将数据导入Pandas数据框,然后在Bokeh中创建可视化。我可以获取html输出文件并将其复制到Google站点的嵌入式小部件中,但这仍然是一个静态可视化。我希望图表在新数据添加到google工作表时刷新。这可能吗?以下是我的代码:

from bokeh.plotting import figure
from bokeh.io import output_file, show, save
from bokeh.resources import CDN
from bokeh.embed import file_html
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd

#Connect to Google Sheet and get data

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name(
         'WUSD Dashboard.json', scope) # Your json file here

gc = gspread.authorize(credentials)

wks = gc.open("Walk Through Data (Responses)").sheet1

data = wks.get_all_values()
headers = data.pop(0)

#Make dataframe from Google Data
#Change data types for numeric columns to numeric data type (they import as a string)

df = pd.DataFrame(data, columns=headers)
df["Engagement (x)"]=pd.to_numeric(df["Engagement (x)"])
df["Evidence of learning (y)"] = pd.to_numeric(df["Evidence of learning (y)"])

cat = df["Site"]
x = df["Engagement (x)"]
y = df["Evidence of learning (y)"]

output_file("Scatter.html")

f = figure()
f.scatter(x,y)

save(f)

如何触发可视化来运行Python脚本,该脚本将在每次加载页面时获取更新的数据?这可能吗?

这有点晚了,但谷歌合作可能是一个可行的选择:


您可以创建一个python“笔记本”,它将按需运行您的代码。这可以存储在Google Drive中,任何人都可以随时在Google Collab上访问和运行它

这有点晚了,但Google Collab可能是一个可行的选择:


您可以创建一个python“笔记本”,它将按需运行您的代码。这可以存储在Google Drive中,任何人都可以随时在Google Collab上访问和运行它

您需要一些地方来运行代码。既然你使用谷歌产品,一个明显的地方就是谷歌功能。嗨,亚当,有没有运气把图形推到谷歌网站上?没有这样的运气。在谷歌生态系统中寻找其他替代方案。DataStudio希望聚合我的所有数据,防止我做基本散点图,因此我正在寻找其他方法来这样做。您需要一些地方来运行代码。既然你使用谷歌产品,一个明显的地方就是谷歌功能。嗨,亚当,有没有运气把图形推到谷歌网站上?没有这样的运气。在谷歌生态系统中寻找其他替代方案。DataStudio希望聚合我所有的数据,防止我做一个基本的散点图,所以我正在寻找其他方法来这样做。