<small id='6CkC9'></small><noframes id='6CkC9'>

    1. <legend id='6CkC9'><style id='6CkC9'><dir id='6CkC9'><q id='6CkC9'></q></dir></style></legend>

          <bdo id='6CkC9'></bdo><ul id='6CkC9'></ul>
        <i id='6CkC9'><tr id='6CkC9'><dt id='6CkC9'><q id='6CkC9'><span id='6CkC9'><b id='6CkC9'><form id='6CkC9'><ins id='6CkC9'></ins><ul id='6CkC9'></ul><sub id='6CkC9'></sub></form><legend id='6CkC9'></legend><bdo id='6CkC9'><pre id='6CkC9'><center id='6CkC9'></center></pre></bdo></b><th id='6CkC9'></th></span></q></dt></tr></i><div id='6CkC9'><tfoot id='6CkC9'></tfoot><dl id='6CkC9'><fieldset id='6CkC9'></fieldset></dl></div>
      1. <tfoot id='6CkC9'></tfoot>
      2. 如何在简单的 Kivy 应用程序中将 Pandas 数据框显示为表格?

        时间:2023-06-07
            <tbody id='0tJoO'></tbody>
          <tfoot id='0tJoO'></tfoot>
        1. <i id='0tJoO'><tr id='0tJoO'><dt id='0tJoO'><q id='0tJoO'><span id='0tJoO'><b id='0tJoO'><form id='0tJoO'><ins id='0tJoO'></ins><ul id='0tJoO'></ul><sub id='0tJoO'></sub></form><legend id='0tJoO'></legend><bdo id='0tJoO'><pre id='0tJoO'><center id='0tJoO'></center></pre></bdo></b><th id='0tJoO'></th></span></q></dt></tr></i><div id='0tJoO'><tfoot id='0tJoO'></tfoot><dl id='0tJoO'><fieldset id='0tJoO'></fieldset></dl></div>

            <small id='0tJoO'></small><noframes id='0tJoO'>

          • <legend id='0tJoO'><style id='0tJoO'><dir id='0tJoO'><q id='0tJoO'></q></dir></style></legend>
              <bdo id='0tJoO'></bdo><ul id='0tJoO'></ul>

                • 本文介绍了如何在简单的 Kivy 应用程序中将 Pandas 数据框显示为表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想构建一个简单的 Kivy 应用:

                  I would like to build a simple Kivy app that:

                  1. 要求用户输入一个整数 (MTP)
                  2. 要求用户输入延迟间隔(delay)
                  3. 在用户按下提交按钮后查询一个url,然后从查询创建一个显示的熊猫数据框(如表)在 Kivy 应用程序的主屏幕上,然后输出更新数据帧,直到 MTP 和延迟间隔结束

                  我将查询的所有代码用作常规 python 程序,我只是不知道如何显示用户输入和输出数据帧(和时间戳).(见下文)

                  I have all the code functioning for the query as a regular python program, I just don't know how to have the user input and the output dataframe (and a time stamp) displayed. (See below)

                  import requests
                  import time
                  from bs4 import BeautifulSoup
                  from datetime import datetime
                  import itertools
                  import pandas as pd
                  
                  mtp = input("Input whole number of minutes to post:") #<-How to do on Kivy Screen
                  delay = input("Enter 15, 30 or 60 second delay:") #<-How to ask on Kivy Screen
                  STP = int(mtp)*60
                  
                  def requestOdds():
                      url = "https://WEBPAGE WITH ODDS DATA.aspx"
                      r = requests.get(url)
                      soup = BeautifulSoup(r.content)
                      stamp = datetime.now().strftime('%m/%d %H:%M:%S')
                      tbPPosts = ('rptOdds_ctl01_tdOdd', 'rptOdds_ctl02_tdOdd','rptOdds_ctl03_tdOdd','rptOdds_ctl04_tdOdd','rptOdds_ctl05_tdOdd','rptOdds_ctl06_tdOdd','rptOdds_ctl07_tdOdd','rptOdds_ctl08_tdOdd','rptOdds_ctl09_tdOdd','rptOdds_ctl10_tdOdd','rptOdds_ctl11_tdOdd','rptOdds_ctl12_tdOdd','rptOdds_ct113_tdOdd','rptOdds_ct114_tdOdd','rptOdds_ct115_tdOdd','rptOdds_ct116_tdOdd','rptOdds_ct117_tdOdd','rptOdds_ct118_tdOdd','rptOdds_ct119_tdOdd','rptOdds_ct120_tdOdd','rptOdds_ct121_tdOdd')
                      mlPPosts = ('rptOdds_ctl01_tdMl','rptOdds_ctl02_tdMl','rptOdds_ctl03_tdMl','rptOdds_ctl04_tdMl','rptOdds_ctl05_tdMl','rptOdds_ctl06_tdMl','rptOdds_ctl07_tdMl','rptOdds_ctl08_tdMl','rptOdds_ctl09_tdOdd','rptOdds_ctl10_tdMl','rptOdds_ctl11_tdMl','rptOdds_ctl12_tdMl','rptOdds_ct113_tdMl','rptOdds_ct114_tdMl','rptOdds_ct115_tdMl','rptOdds_ct116_tdMl', 'rptOdds_ct117_tdMl','rptOdds_ct118_tdMl','rptOdds_ct119_tdMl','rptOdds_ct120_tdMl','rptOdds_ct121_tdMl')
                      trimmed_text=[]
                      trimmed_text2=[]
                      tbodds = []
                      mlodds = []
                      odds = []
                  
                      for horse in tbPPosts:
                          table = soup.find('td', {"odds-table-odd"}, id=horse)
                          if table is not None:
                              text = table.renderContents()
                              trimmed_text = text.strip()
                              tbodds.append(trimmed_text) 
                  
                      for mlhorse in mlPPosts:
                          table2 = soup.find('td', {"odds-table-ml"}, id=mlhorse)
                          if table2 is not None:
                              text2 = table2.renderContents()
                              trimmed_text2 = text2.strip()
                              mlodds.append(trimmed_text2)
                  
                      mlodds = itertools.ifilterfalse(lambda x: x=='', mlodds) #faster
                      tbodds = itertools.ifilterfalse(lambda x: x=='', tbodds)
                      oddsDict = dict(zip(mlodds, tbodds))
                      **odds = pd.DataFrame(list(oddsDict.iteritems()), columns=['ML','TB'])
                      print odds, stamp** #<--How do I get these to print onto the Kivy Screen?
                  
                  def getLiveOdds():
                      interval = 0
                      while interval <= STP:
                          requestOdds()
                          time.sleep(delay)
                          interval +=delay
                  
                  getLiveOdds()
                  

                  任何帮助将不胜感激!

                  推荐答案

                  我发现了一些可以帮助你的东西:

                  I found out something which could help you :

                  基维文件

                  GraphDraw:
                  
                  <GraphDraw>:
                  
                      BoxLayout:
                          Button:
                              text: "Hello World"
                              on_press: root.graph()
                  

                  逻辑

                  #!/usr/bin/env python
                  # -*- encoding: utf-8
                  
                  import datetime
                  import pandas as pd
                  from kivy.app import App
                  from kivy.uix.boxlayout import BoxLayout
                  import dfgui
                  import pandas as pd
                  
                  
                  class Visualisation(App):
                      pass
                  
                  class GraphDraw(BoxLayout):
                      def graph(self):
                          xls = pd.read_excel('filepath')
                          #df = pd.DataFrame.xls
                          dfgui.show(xls)
                          #print xls
                  
                  if __name__ == '__main__':
                      Visualisation().run()
                  

                  所以您使用 dfgui 可以创建 pandas 数据框表,而不是使用 Kivy.查看项目 dfgui:https://github.com/bluenote10/PandasDataFrameGUI

                  So you use dfgui which can create pandas dataframe table instead of using Kivy. See the project dfgui : https://github.com/bluenote10/PandasDataFrameGUI

                  希望对你有帮助:)

                  这篇关于如何在简单的 Kivy 应用程序中将 Pandas 数据框显示为表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Kivy 布局高度以适应子小部件的高度 下一篇:如何获取在 Kivy 中使用 fileChooser 选择的文件的信息?

                  相关文章

                  1. <i id='w8w1m'><tr id='w8w1m'><dt id='w8w1m'><q id='w8w1m'><span id='w8w1m'><b id='w8w1m'><form id='w8w1m'><ins id='w8w1m'></ins><ul id='w8w1m'></ul><sub id='w8w1m'></sub></form><legend id='w8w1m'></legend><bdo id='w8w1m'><pre id='w8w1m'><center id='w8w1m'></center></pre></bdo></b><th id='w8w1m'></th></span></q></dt></tr></i><div id='w8w1m'><tfoot id='w8w1m'></tfoot><dl id='w8w1m'><fieldset id='w8w1m'></fieldset></dl></div>
                    <tfoot id='w8w1m'></tfoot>
                    • <bdo id='w8w1m'></bdo><ul id='w8w1m'></ul>

                    <small id='w8w1m'></small><noframes id='w8w1m'>

                    <legend id='w8w1m'><style id='w8w1m'><dir id='w8w1m'><q id='w8w1m'></q></dir></style></legend>