Home>
I want to calculate the winning percentage for each ID from the data
** Please write your question in detail here.
** **
import sqlite3
filepath = "test2.sqlite"
conn = sqlite3.connect (filepath)
cur = conn.cursor ()
cur.execute ("DROP TABLE IF EXISTS items")
cur.execute ("" "CREATE TABLE items ("" "
id PRIMARY KEY,
time INTEGER
id2 INTEGER,
result INTEGER
) "" ")
conn.commit ()
cur = conn.cursor ()
data = [(1,20200619 12:00,1,1),
(1,20200819 13:00,2,1),
(1,20200819 13:00,2,0),
(3,20200823,14: 00,1,0),
(2,20200823,14: 00,1,0),
(2,20200823,14: 00,1,1),
(1,20200823,14: 00,1,0),
(3,20200823,15: 00,2,1)]
Win rate when 1 wins and 0 loses in Result
I want to calculate using SQL for each ID.
SQL + python

Answer # 1
Related articles
 python  how do you calculate the percentage from the data frame?
 python: calculate the maximum partial sum of lists
 i want to calculate the correlation coefficient and coefficient of determination of a nonlinear regression curve in python
 how to calculate (examine the range) what is extracted from the text in python
 python 3x  i want to calculate a physical phenomenon
 how to calculate datetime in python ~ datetime error ~
 i want to calculate the date interval in python
 python  i want to calculate all the elements in the list and rotate them
 python  how to read the f distribution table (percentage point)
 calculate with significant figures in python
 [python] i want to calculate a matrix for each area and reduce its size
 [python] i want to calculate matrices of different sizes using iteration
 [python] i want to calculate a matrix with a strange law
 [python] i want to calculate an excel matrix with a for statement
 python  i want to calculate matrix calculation with numpy for statement with numpydot
Related questions
 python : POSTGRESQL queries caching
 python : QStyLeDiteMDelegate problem with the preservation of entered data
 python : Creating an aggregator site
 python : QSQLTableModel Vertical title
 python : How to output the result of the query from the database, in the Django pattern
 python : problem with issuing role
 python : How to Remove Quotes When Querying An SQL Database
 python : How to parse the values from RESULT [i]
 python : How can I connect the already available table (.sql) to the file in Pyhton and how to access it
 python : How to change the entry in the database using Django ORM in one request
No commentary needed, right?