Jupyter-如何对功能进行交互式更新?
def sort_category (category, file_source):
file = file_source.loc[file_source['Odds Category'] == category]
return file
def plot_graph (a, b):
plt.plot(a,b)
def calcul (bankroll_init, bet_init, multiplier, odds_category, file_source):
sorted_file = sort_category(odds_category, file_source)
bankroll_current = bankroll_init
bet_current = bet_init
list_bankroll = []
list_date = []
for i in sorted_file.index:
list_bankroll.append(bankroll_current)
list_date.append(sorted_file['Date'][i])
bankroll_current = bankroll_current - bet_current
if (sorted_file['B365H'][i] == sorted_file['Min Odds'][i]) & (sorted_file['FTR'][i] == 'H'):
bankroll_current = bankroll_current + (bet_current * sorted_file['B365H'][i])
bet_current = bet_init
elif (sorted_file['B365A'][i] == sorted_file['Min Odds'][i]) & (sorted_file['FTR'][i] == 'A'):
bankroll_current = bankroll_current + (bet_current * sorted_file['B365A'][i])
bet_current = bet_init
else :
bet_current = bet_current * multiplier
plot_graph(list_date,list_bankroll)
calcul(10000,10,2,4,ligue_1)
该代码通过“ plot_graph”函数绘制图形,该函数在'calcul'函数中被称为。
有没有一种方法可以通过滑块或下拉菜单更新我的“计算”功能的五个参数?这些参数是改变图形的条件。
谢谢
def sort_category (category, file_source):
file = file_source.loc[file_source['Odds Category'] == category]
return file
def plot_graph (a, b):
plt.plot(a,b)
def calcul (bankroll_init, bet_init, multiplier, odds_category, file_source):
sorted_file = sort_category(odds_category, file_source)
bankroll_current = bankroll_init
bet_current = bet_init
list_bankroll = []
list_date = []
for i in sorted_file.index:
list_bankroll.append(bankroll_current)
list_date.append(sorted_file['Date'][i])
bankroll_current = bankroll_current - bet_current
if (sorted_file['B365H'][i] == sorted_file['Min Odds'][i]) & (sorted_file['FTR'][i] == 'H'):
bankroll_current = bankroll_current + (bet_current * sorted_file['B365H'][i])
bet_current = bet_init
elif (sorted_file['B365A'][i] == sorted_file['Min Odds'][i]) & (sorted_file['FTR'][i] == 'A'):
bankroll_current = bankroll_current + (bet_current * sorted_file['B365A'][i])
bet_current = bet_init
else :
bet_current = bet_current * multiplier
plot_graph(list_date,list_bankroll)
calcul(10000,10,2,4,ligue_1)
This code plot a graphic through the "plot_graph" function, which is called in the 'calcul' function.
Is there a way to update the five arguments of my 'calcul' function with sliders or dropdown menus ? These arguments are conditions that change the graphic.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
我留给您以适应您的情况:
ipywidgets库中有很多小部件,您可以发现在这里。在示例中,我只放了很少的内容,因此您可以看到我们如何使用
I leave it to you to adapt this code for your case :
there are lot of widgets in ipywidgets library that you can discover here. In the example I put only few of them so you can see how do we use