<tfoot id='QbhHI'></tfoot>

    1. <small id='QbhHI'></small><noframes id='QbhHI'>

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

        如何在简单的 Kivy 应用程序中将 Pandas 数据框显示

        时间:2023-10-10

      2. <tfoot id='6CCHG'></tfoot>

            <legend id='6CCHG'><style id='6CCHG'><dir id='6CCHG'><q id='6CCHG'></q></dir></style></legend>

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

              <i id='6CCHG'><tr id='6CCHG'><dt id='6CCHG'><q id='6CCHG'><span id='6CCHG'><b id='6CCHG'><form id='6CCHG'><ins id='6CCHG'></ins><ul id='6CCHG'></ul><sub id='6CCHG'></sub></form><legend id='6CCHG'></legend><bdo id='6CCHG'><pre id='6CCHG'><center id='6CCHG'></center></pre></bdo></b><th id='6CCHG'></th></span></q></dt></tr></i><div id='6CCHG'><tfoot id='6CCHG'></tfoot><dl id='6CCHG'><fieldset id='6CCHG'></fieldset></dl></div>
                <tbody id='6CCHG'></tbody>
                <bdo id='6CCHG'></bdo><ul id='6CCHG'></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 数据框显示为表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                      • <bdo id='hbfci'></bdo><ul id='hbfci'></ul>

                      <tfoot id='hbfci'></tfoot>
                      <legend id='hbfci'><style id='hbfci'><dir id='hbfci'><q id='hbfci'></q></dir></style></legend>

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