Refactored scripts
This commit is contained in:
1 parent
265bb31e27
commit
fb290579c1
21 files changed
+136
-368
No files matched your search
@@ -15,6 +15,7 @@ ENV/
|
|||||||
env.bak/
|
env.bak/
|
||||||
venv.bak/
|
venv.bak/
|
||||||
.kolo/
|
.kolo/
|
||||||
|
.directory
|
||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
out/
|
out/
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Excel
|
||||||
|
*.xlsx
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
WVLotto.py
|
lotto.py
|
||||||
|
|
||||||
This script generates the five most likely lottery numbers and one powerball, based off frequency pulled.
|
This script generates the most likely lottery numbers based off frequency of winning numbers.
|
||||||
|
|
||||||
This script uses an excel sheet to store the history of all WV Lottery numbers since 1992. It does NOT however guarantee you will win.
|
Previously there were records dating back to 1992 that were removed by the website, which has lead me to rewrite and encourage the collaboration and sharing of this work.
|
||||||
|
|
||||||
|
I am welcoming anyone who wants to to port it to their own state to do so. I currently have a website hosting my numbers to be refreshed daily. Collaboration and suggestion at a more accurate algorithm is also welcome.
|
||||||
|
|
||||||
Good luck!
|
Good luck!
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
Winning_Numbers,Chance
|
Winning_Numbers,Chance
|
||||||
14-18-2-22-5-9,49/25300
|
14-18-2-22-5-9,31/16100
|
||||||
|
@@ -1,55 +1,29 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/cash-25/?game-analyze=cash-25&what-to-search=historysearch&date-range=-1'
|
def get_data():
|
||||||
header = {
|
url = 'https://wvlottery.com/draw-games/cash-25/?game-analyze=cash-25&what-to-search=historysearch&date-range=-1'
|
||||||
|
header = {
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get web data
|
# Get web data
|
||||||
r = requests.get(url, headers=header)
|
r = requests.get(url, headers=header)
|
||||||
dfs = pd.read_html(r.text)
|
dfs = pd.read_html(r.text)
|
||||||
pd.set_option('display.max_rows', None)
|
pd.set_option('display.max_rows', None)
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
#print(len(dfs))
|
df = dfs[0]
|
||||||
df = dfs[0]
|
df2 = df[['Date', 'Numbers']]
|
||||||
df2 = df[['Date', 'Numbers']]
|
date = list(df2['Date'])
|
||||||
# Print Table
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
#print(df2)
|
return date, nums
|
||||||
|
|
||||||
# To excel file
|
date, nums = get_data()
|
||||||
df2.to_excel('./cash25.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("cash25.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
#PB = list(df['PB'].astype('int'))
|
|
||||||
#appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='cash25.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='cash25.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -63,17 +37,14 @@ for n in range(0, 25):
|
|||||||
likely_nums = [v[0] for v in most_common]
|
likely_nums = [v[0] for v in most_common]
|
||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
#for n in range(0, 26):
|
|
||||||
# most_common_pb = Counter(PB).most_common(1)
|
|
||||||
# likely_pb = [v[0] for v in most_common_pb]
|
|
||||||
# frequency_pb = [v[-1] for v in most_common_pb]
|
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency)
|
total_freq = sum(frequency)
|
||||||
Chance = frac(total_freq, 177100) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 177100) # Chance = number call freq / all possible numbers i.e. 177100
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers} \n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
||||||
h = 'Winning_Numbers', 'Chance'
|
h = 'Winning_Numbers', 'Chance'
|
||||||
f = open('c25_ans.csv', 'w', encoding='utf_8')
|
f = open('c25_ans.csv', 'w', encoding='utf_8')
|
||||||
|
|||||||
Binary file not shown.
@@ -1,2 +1,2 @@
|
|||||||
Winning_Numbers,Chance
|
Winning_Numbers,Chance
|
||||||
0-3-8,33/10000
|
0-3-8,3/100
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
Winning_Numbers,Chance
|
Winning_Numbers,Chance
|
||||||
3-5-6-8,537/10000
|
3-5-6-8,67/1250
|
||||||
|
@@ -1,55 +1,28 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=1'
|
def get_data():
|
||||||
header = {
|
url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=1'
|
||||||
|
header = {
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
# Get web data
|
||||||
|
r = requests.get(url, headers=header)
|
||||||
|
dfs = pd.read_html(r.text)
|
||||||
|
pd.set_option('display.max_rows', None)
|
||||||
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
|
df = dfs[0]
|
||||||
|
df2 = df[['Date', 'Numbers']]
|
||||||
|
date = list(df2['Date'])
|
||||||
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
|
return date, nums
|
||||||
|
|
||||||
# Get web data
|
date, nums = get_data()
|
||||||
r = requests.get(url, headers=header)
|
|
||||||
dfs = pd.read_html(r.text)
|
|
||||||
pd.set_option('display.max_rows', None)
|
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
|
||||||
#print(len(dfs))
|
|
||||||
df = dfs[0]
|
|
||||||
df2 = df[['Date', 'Numbers']]
|
|
||||||
# Print Table
|
|
||||||
#print(df2)
|
|
||||||
|
|
||||||
# To excel file
|
|
||||||
df2.to_excel('./daily3.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("daily3.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
#PB = list(df['PB'].astype('int'))
|
|
||||||
#appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
#index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='daily3.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='daily3.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -63,17 +36,13 @@ for n in range(0, 10):
|
|||||||
likely_nums = [v[0] for v in most_common]
|
likely_nums = [v[0] for v in most_common]
|
||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
#for n in range(0, 26):
|
|
||||||
# most_common_pb = Counter(PB).most_common(1)
|
|
||||||
# likely_pb = [v[0] for v in most_common_pb]
|
|
||||||
# frequency_pb = [v[-1] for v in most_common_pb]
|
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency)
|
total_freq = sum(frequency)
|
||||||
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 1000) # Chance = number call freq / all possible numbers i.e. 1000
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers} \n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
||||||
h = 'Winning_Numbers', 'Chance'
|
h = 'Winning_Numbers', 'Chance'
|
||||||
|
|||||||
Binary file not shown.
@@ -1,55 +1,28 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/daily-4/?game-analyze=daily-4&what-to-search=historysearch&date-range=-1'
|
def get_data():
|
||||||
header = {
|
url = 'https://wvlottery.com/draw-games/daily-4/?game-analyze=daily-4&what-to-search=historysearch&date-range=-1'
|
||||||
|
header = {
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
# Get web data
|
||||||
|
r = requests.get(url, headers=header)
|
||||||
|
dfs = pd.read_html(r.text)
|
||||||
|
pd.set_option('display.max_rows', None)
|
||||||
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
|
df = dfs[0]
|
||||||
|
df2 = df[['Date', 'Numbers']]
|
||||||
|
date = list(df2['Date'])
|
||||||
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
|
return date, nums
|
||||||
|
|
||||||
# Get web data
|
date, nums = get_data()
|
||||||
r = requests.get(url, headers=header)
|
|
||||||
dfs = pd.read_html(r.text)
|
|
||||||
pd.set_option('display.max_rows', None)
|
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
|
||||||
#print(len(dfs))
|
|
||||||
df = dfs[0]
|
|
||||||
df2 = df[['Date', 'Numbers']]
|
|
||||||
# Print Table
|
|
||||||
#print(df2)
|
|
||||||
|
|
||||||
# To excel file
|
|
||||||
df2.to_excel('./daily4.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("daily4.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
#PB = list(df['PB'].astype('int'))
|
|
||||||
#appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
#index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='daily4.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='daily4.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -63,17 +36,14 @@ for n in range(0, 9):
|
|||||||
likely_nums = [v[0] for v in most_common]
|
likely_nums = [v[0] for v in most_common]
|
||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
#for n in range(0, 26):
|
|
||||||
# most_common_pb = Counter(PB).most_common(1)
|
|
||||||
# likely_pb = [v[0] for v in most_common_pb]
|
|
||||||
# frequency_pb = [v[-1] for v in most_common_pb]
|
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency)
|
total_freq = sum(frequency)
|
||||||
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 10000
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers}, \n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers','Chance')))
|
||||||
h = 'Winning_Numbers', 'Chance'
|
h = 'Winning_Numbers', 'Chance'
|
||||||
f = open('d4_ans.csv', 'w', encoding='utf_8')
|
f = open('d4_ans.csv', 'w', encoding='utf_8')
|
||||||
|
|||||||
Binary file not shown.
@@ -1,2 +1,2 @@
|
|||||||
Winning_Numbers,SB,Chance
|
Winning_Numbers,SB,Chance
|
||||||
1-10-32-49-8,[9],1/265200
|
1-10-27-32-8,[9],1/270725
|
||||||
|
Binary file not shown.
@@ -1,56 +1,31 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
#from django_lottopy.lottopy_site.lottopy.lottopy_web_edition.megamil import Winning_Numbers
|
#from django_lottopy.lottopy_site.lottopy.lottopy_web_edition.megamil import Winning_Numbers
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/lotto-america/?game-analyze=lotto-america&what-to-search=historysearch&date-range=-1'
|
def get_data():
|
||||||
header = {
|
url = 'https://wvlottery.com/draw-games/lotto-america/?game-analyze=lotto-america&what-to-search=historysearch&date-range=-1'
|
||||||
|
header = {
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get web data
|
# Get web data
|
||||||
r = requests.get(url, headers=header)
|
r = requests.get(url, headers=header)
|
||||||
dfs = pd.read_html(r.text)
|
dfs = pd.read_html(r.text)
|
||||||
pd.set_option('display.max_rows', None)
|
pd.set_option('display.max_rows', None)
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
#print(len(dfs))
|
df = dfs[0]
|
||||||
df = dfs[0]
|
df2 = df[['Date', 'Numbers', 'SB', 'All Star']]
|
||||||
df2 = df[['Date', 'Numbers', 'SB', 'All Star']]
|
date = list(df2['Date'])
|
||||||
# Print Table
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
#print(df2)
|
SBs = list(df2['SB'].astype('int'))
|
||||||
|
return date, nums, SBs
|
||||||
|
|
||||||
# To excel file
|
date, nums, SBs = get_data()
|
||||||
df2.to_excel('./lotto_america.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("lotto_america.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
PBs = list(df['SB'].astype('int'))
|
|
||||||
#appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='lotto_america.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='lotto_america.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -65,16 +40,18 @@ for n in range(0, 52):
|
|||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
for n in range(0, 10):
|
for n in range(0, 10):
|
||||||
most_common_pb = Counter(PBs).most_common(1)
|
most_common_sb = Counter(SBs).most_common(1)
|
||||||
SB = [v[0] for v in most_common_pb]
|
SB = [v[0] for v in most_common_sb]
|
||||||
frequency_pb = [v[-1] for v in most_common_pb]
|
frequency_sb = [v[-1] for v in most_common_sb]
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency + frequency_pb)
|
total_freq = sum(frequency + frequency_sb)
|
||||||
Chance = frac(total_freq, 25989600) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 25989600) # Chance = number call freq / all possible numbers i.e. 25,989,600
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "SB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers} SB: {SB}\n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'SB', 'Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'SB', 'Chance')))
|
||||||
h = 'Winning_Numbers', 'SB', 'Chance'
|
h = 'Winning_Numbers', 'SB', 'Chance'
|
||||||
f = open('la_ans.csv', 'w', encoding='utf_8')
|
f = open('la_ans.csv', 'w', encoding='utf_8')
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,58 +1,29 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
def fraction_ratio(i):
|
def get_data():
|
||||||
return i/sum(i)
|
url = 'https://wvlottery.com/draw-games/powerball/?game-analyze=powerball&what-to-search=historysearch&date-range=-1'
|
||||||
|
header = {
|
||||||
url = 'https://wvlottery.com/draw-games/powerball/?game-analyze=powerball&what-to-search=historysearch&date-range=-1'
|
|
||||||
header = {
|
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
# Get web data
|
||||||
|
r = requests.get(url, headers=header)
|
||||||
|
dfs = pd.read_html(r.text)
|
||||||
|
pd.set_option('display.max_rows', None)
|
||||||
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
|
df = dfs[0]
|
||||||
|
df2 = df[['Date', 'Numbers', 'PB', 'PPX', 'Winners WV Only', 'Payout WV Only']]
|
||||||
|
date = list(df2['Date'])
|
||||||
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
|
PBs = list(df2['PB'].astype('int'))
|
||||||
|
return date, nums, PBs
|
||||||
|
|
||||||
# Get web data
|
date, nums, PBs = get_data()
|
||||||
r = requests.get(url, headers=header)
|
|
||||||
dfs = pd.read_html(r.text)
|
|
||||||
pd.set_option('display.max_rows', None)
|
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
|
||||||
#print(len(dfs))
|
|
||||||
df = dfs[0]
|
|
||||||
df2 = df[['Date', 'Numbers', 'PB', 'PPX', 'Winners WV Only', 'Payout WV Only']]
|
|
||||||
# Print Table
|
|
||||||
#print(df2)
|
|
||||||
|
|
||||||
# To excel file
|
|
||||||
df2.to_excel('./lotto.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("lotto.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
PBs = list(df['PB'].astype('int'))
|
|
||||||
appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='lotto.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='lotto.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -62,7 +33,7 @@ splitlist = ", ".join(hyphenfree)
|
|||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
|
|
||||||
for n in range(0, 69):
|
for n in range(0, 69):
|
||||||
most_common= Counter(sep).most_common(5)
|
most_common = Counter(sep).most_common(5)
|
||||||
likely_nums = [v[0] for v in most_common]
|
likely_nums = [v[0] for v in most_common]
|
||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
@@ -73,10 +44,11 @@ for n in range(0, 26):
|
|||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency + frequency_pb)
|
total_freq = sum(frequency + frequency_pb)
|
||||||
Chance = frac(total_freq, 292201338) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 292201338) # Chance = number call freq / all possible numbers i.e. 292201338
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "PB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers} PB: {PB}\n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'PB', 'Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'PB', 'Chance')))
|
||||||
h = 'Winning_Numbers', 'PB', 'Chance'
|
h = 'Winning_Numbers', 'PB', 'Chance'
|
||||||
|
|||||||
@@ -1,55 +1,31 @@
|
|||||||
# WVLottopy megamil: Matteo DiBiagio
|
# WVLottopy megamil: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/mega-millions/?game-analyze=mega-millions&what-to-search=historysearch&date-range=-1'
|
|
||||||
header = {
|
def get_data():
|
||||||
|
url = 'https://wvlottery.com/draw-games/mega-millions/?game-analyze=mega-millions&what-to-search=historysearch&date-range=-1'
|
||||||
|
header = {
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
"X-Requested-With": "XMLHttpRequest"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get web data
|
# Get web data
|
||||||
r = requests.get(url, headers=header)
|
r = requests.get(url, headers=header)
|
||||||
dfs = pd.read_html(r.text)
|
dfs = pd.read_html(r.text)
|
||||||
pd.set_option('display.max_rows', None)
|
pd.set_option('display.max_rows', None)
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
# Specifies no max rows, otherwise only shows 10 records
|
||||||
#print(len(dfs))
|
df = dfs[0]
|
||||||
df = dfs[0]
|
df2 = df[['Date', 'Numbers', 'MB', 'MP']]
|
||||||
df2 = df[['Date', 'Numbers', 'MB', 'MP']]
|
date = list(df2['Date'])
|
||||||
# Print Table
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
#print(df2)
|
MBs = list(df2['MB'].astype('int'))
|
||||||
|
return date, nums, MBs
|
||||||
|
|
||||||
# To excel file
|
date, nums, MBs = get_data()
|
||||||
df2.to_excel('./lotto_megamil.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("lotto_megamil.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
PBs = list(df['MB'].astype('int'))
|
|
||||||
#appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='lotto_megamil.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='lotto_megamil.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
@@ -64,16 +40,18 @@ for n in range(0, 70):
|
|||||||
frequency = [v[-1] for v in most_common]
|
frequency = [v[-1] for v in most_common]
|
||||||
|
|
||||||
for n in range(0, 25):
|
for n in range(0, 25):
|
||||||
most_common_pb = Counter(PBs).most_common(1)
|
most_common_mb = Counter(MBs).most_common(1)
|
||||||
MB = [v[0] for v in most_common_pb]
|
MB = [v[0] for v in most_common_mb]
|
||||||
frequency_pb = [v[-1] for v in most_common_pb]
|
frequency_mb = [v[-1] for v in most_common_mb]
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
sorted_nums = sorted(likely_nums)
|
||||||
total_freq = sum(frequency + frequency_pb)
|
total_freq = sum(frequency + frequency_mb)
|
||||||
Chance = frac(total_freq, 302575350) # Chance = number call freq / all possible numbers i.e. 11238513
|
Chance = frac(total_freq, 302575350) # Chance = number call freq / all possible numbers i.e. 11238513
|
||||||
Winning_Numbers = str("-".join(sorted_nums))
|
Winning_Numbers = str("-".join(sorted_nums))
|
||||||
|
|
||||||
#print("Likely numbers are . . . ", sorted_nums, "MB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
#print(f"Likely numbers are . . . {Winning_Numbers} MB: {MB}\n"
|
||||||
|
#f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'MB', 'Chance')))
|
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'MB', 'Chance')))
|
||||||
h = 'Winning_Numbers', 'MB', 'Chance'
|
h = 'Winning_Numbers', 'MB', 'Chance'
|
||||||
f = open('mm_ans.csv', 'w', encoding='utf_8')
|
f = open('mm_ans.csv', 'w', encoding='utf_8')
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
pandas==1.3.5
|
pandas==1.3.5
|
||||||
requests==2.26.0
|
requests==2.26.0
|
||||||
sheet2dict==0.1.1
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
|
||||||
from sheet2dict import Worksheet
|
|
||||||
import pandas as pd
|
|
||||||
import requests
|
|
||||||
from collections import Counter
|
|
||||||
|
|
||||||
url = 'https://wvlottery.com/draw-games/powerball/?game-analyze=powerball&what-to-search=historysearch&date-range=-1'
|
|
||||||
header = {
|
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
|
||||||
"X-Requested-With": "XMLHttpRequest"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get web data
|
|
||||||
r = requests.get(url, headers=header)
|
|
||||||
dfs = pd.read_html(r.text)
|
|
||||||
pd.set_option('display.max_rows', None)
|
|
||||||
# Specifies no max rows, otherwise only shows 10 records
|
|
||||||
#print(len(dfs))
|
|
||||||
df = dfs[0]
|
|
||||||
df2 = df[['Date', 'Numbers', 'PB', 'PPX', 'Winners WV Only', 'Payout WV Only']]
|
|
||||||
# Print Table
|
|
||||||
#print(df2)
|
|
||||||
|
|
||||||
# To excel file
|
|
||||||
df2.to_excel('../lottopy/lotto.xlsx')
|
|
||||||
|
|
||||||
#Insert complete path to the excel file and index of the worksheet
|
|
||||||
df = pd.read_excel("lotto.xlsx", sheet_name=0)
|
|
||||||
|
|
||||||
# insert the name of the column as a string in brackets
|
|
||||||
date = list(df['Date'])
|
|
||||||
nums = list(df['Numbers'].astype('str'))
|
|
||||||
PB = list(df['PB'].astype('int'))
|
|
||||||
appearances = list(df2['Winners WV Only'].astype('int'))
|
|
||||||
|
|
||||||
# Index for each row
|
|
||||||
index = [i for i in range(0,len(nums)*6)]
|
|
||||||
|
|
||||||
# Create an object
|
|
||||||
ws = Worksheet()
|
|
||||||
|
|
||||||
# Convert active sheet (without specifying sheet name)
|
|
||||||
ws.xlsx_to_dict(path='lotto.xlsx')
|
|
||||||
|
|
||||||
# Convert sheet of the 'lotto.xslx' spreadsheet file.
|
|
||||||
ws.xlsx_to_dict(path='lotto.xlsx', select_sheet='Sheet1')
|
|
||||||
|
|
||||||
# object.header returns first row with the data in a spreadsheet, object.sheet_items returns converted rows as dictionaries in the array
|
|
||||||
#print(ws.header)
|
|
||||||
#print(ws.sheet_items)
|
|
||||||
|
|
||||||
# Formatting
|
|
||||||
hyphenfree = []
|
|
||||||
for x in nums:
|
|
||||||
hyphenfree.append(x.replace('-',', '))
|
|
||||||
splitlist = ", ".join(hyphenfree)
|
|
||||||
sep = splitlist.split(", ")
|
|
||||||
|
|
||||||
for n in range(0, 69):
|
|
||||||
most_common= Counter(sep).most_common(5)
|
|
||||||
likely_nums = [v[0] for v in most_common]
|
|
||||||
frequency = [v[-1] for v in most_common]
|
|
||||||
|
|
||||||
for n in range(0, 26):
|
|
||||||
most_common_pb = Counter(PB).most_common(1)
|
|
||||||
likely_pb = [v[0] for v in most_common_pb]
|
|
||||||
frequency_pb = [v[-1] for v in most_common_pb]
|
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums)
|
|
||||||
total_freq = sum(frequency + frequency_pb)
|
|
||||||
chance = [(total_freq / 292201338) * 100] # Chance = number call freq / all possible numbers i.e. 11238513
|
|
||||||
|
|
||||||
print("Likely numbers are . . . ", sorted_nums, "PB:", likely_pb, "\n", "With percent chance of winning being", chance[0]*100, "%")
|
|
||||||
Reference in new issue
Block a user