Updating repo with submodule, removing .pyc files and fixing bugs
This commit is contained in:
1 parent
a8b3c89645
commit
96c3078cd0
1569 files changed
+4
-553
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Submodule
+1
Submodule lottopy_site/lottopy/lottopy_web_edition added at f52dd964ad.
@@ -1,2 +0,0 @@
|
||||
# Redis?
|
||||
dump.rdb
|
||||
@@ -1,11 +0,0 @@
|
||||
lotto.py
|
||||
|
||||
This script generates the most likely lottery numbers based off frequency of winning numbers.
|
||||
|
||||
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!
|
||||
|
||||
Old numbers have been re-added to analysis.
|
||||
@@ -1,2 +0,0 @@
|
||||
Forecast,Chance
|
||||
1 - 4 - 16 - 18 - 19 - 20,1/177100
|
||||
|
@@ -1,71 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
from math import comb
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/cash25.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=10&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
return date, nums
|
||||
|
||||
date, nums = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
||||
# so the old records have some numbers that dont exist in the game anymore
|
||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 25]
|
||||
|
||||
for n in range(0, 25):
|
||||
most_common= Counter(sep).most_common(6)
|
||||
likely_nums = [v[0] for v in most_common]
|
||||
frequency = [v[-1] for v in most_common]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = 1 / every possible ticket, 25 choose 6 = 177100
|
||||
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
|
||||
Chance = frac(1, comb(25, 6))
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} \n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast','Chance')))
|
||||
h = 'Forecast', 'Chance'
|
||||
f = open('c25_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
@@ -1,58 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=24&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, cash pop draws every 15 min so only use the last ~3000 draws (about a month)
|
||||
web = {'Date': [], 'Numbers': []}
|
||||
page = 0
|
||||
while page < 6:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
df2 = pd.DataFrame(web)
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
return date, nums
|
||||
|
||||
date, nums = get_data()
|
||||
|
||||
# Formatting
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only keep 1 - 15, just in case anything weird comes back from the site
|
||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 15]
|
||||
|
||||
for n in range(0, 15):
|
||||
most_common= Counter(sep).most_common(3)
|
||||
likely_nums = [v[0] for v in most_common]
|
||||
frequency = [v[-1] for v in most_common]
|
||||
|
||||
Forecast = likely_nums[0]
|
||||
Backups = str(" - ".join(likely_nums[1:]))
|
||||
Chance = frac(1, 15) # Only one number is drawn out of 15 so every pick has the same chance
|
||||
|
||||
#print(f"Likely number is . . . {Forecast} Backups: {Backups}\n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast', 'Backups', 'Chance')))
|
||||
h = 'Forecast', 'Backups', 'Chance'
|
||||
f = open('cp_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
@@ -1,2 +0,0 @@
|
||||
Forecast,Backups,Chance
|
||||
1,11 - 4,1/15
|
||||
|
@@ -1,17 +0,0 @@
|
||||
# Powerball
|
||||
45 23 * * 1,3,6
|
||||
|
||||
# Mega Mil
|
||||
50 23 * * 2,5
|
||||
|
||||
# Lotto America
|
||||
0 23 * * 1,3,6
|
||||
|
||||
# D3, D4 (Every day but sunday 7:45)
|
||||
45 19 * * 1,2,3,4,5,6
|
||||
|
||||
# C25 (Mon, Tue, Thu, Fri 7:45)
|
||||
45 19 * * 1,2,4,5
|
||||
|
||||
# Cash Pop (every hour 5:20 AM - 11:20 PM, lottery site is down 12-4 AM)
|
||||
20 5-23 * * *
|
||||
@@ -1,2 +0,0 @@
|
||||
Forecast,Chance
|
||||
3 - 7 - 8,3/500
|
||||
|
@@ -1,2 +0,0 @@
|
||||
Forecast,Chance
|
||||
1 - 2 - 4 - 6,3/1250
|
||||
|
@@ -1,69 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/daily3.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=9&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
return date, nums
|
||||
|
||||
date, nums = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only keep actual digits, gets rid of any blanks from the excel records
|
||||
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
||||
|
||||
for n in range(0, 10):
|
||||
most_common= Counter(sep).most_common(3)
|
||||
likely_nums = [v[0] for v in most_common]
|
||||
frequency = [v[-1] for v in most_common]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = playing the forecast as a box (any order), 3 different digits can come up 6 ways out of 1000 = 3/500
|
||||
# playing it straight (exact order) is 1/1000
|
||||
Chance = frac(6, 1000)
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} \n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast','Chance')))
|
||||
h = 'Forecast', 'Chance'
|
||||
f = open('d3_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
@@ -1,69 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/daily4.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=14&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
return date, nums
|
||||
|
||||
date, nums = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only keep actual digits, gets rid of any blanks from the excel records
|
||||
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
||||
|
||||
for n in range(0, 9):
|
||||
most_common= Counter(sep).most_common(4)
|
||||
likely_nums = [v[0] for v in most_common]
|
||||
frequency = [v[-1] for v in most_common]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = playing the forecast as a box (any order), 4 different digits can come up 24 ways out of 10000 = 3/1250
|
||||
# playing it straight (exact order) is 1/10000
|
||||
Chance = frac(24, 10000)
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} \n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast','Chance')))
|
||||
h = 'Forecast', 'Chance'
|
||||
f = open('d4_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
Forecast,SB,Chance
|
||||
1 - 8 - 15 - 35 - 51,[4],1/25989600
|
||||
|
@@ -1,80 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
from math import comb
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers', 'SB']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=16&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': [], 'SB': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
web['SB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers', 'SB']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
SBs = list(df2['SB'].astype('int'))
|
||||
return date, nums, SBs
|
||||
|
||||
date, nums, SBs = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
||||
# so the old records have some numbers that dont exist in the game anymore
|
||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 52]
|
||||
SBs = [x for x in SBs if 1 <= x <= 10]
|
||||
|
||||
for n in range(0, 52):
|
||||
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, 10):
|
||||
most_common_sb = Counter(SBs).most_common(1)
|
||||
SB = [v[0] for v in most_common_sb]
|
||||
frequency_sb = [v[-1] for v in most_common_sb]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = 1 / every possible ticket, 52 choose 5 white balls times 10 star balls = 25989600
|
||||
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
|
||||
Chance = frac(1, comb(52, 5) * 10)
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} SB: {SB}\n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast', 'SB', 'Chance')))
|
||||
h = 'Forecast', 'SB', 'Chance'
|
||||
f = open('la_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
# WVLottopy: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
from math import comb
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/lotto.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers', 'PB']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=12&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': [], 'PB': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
web['PB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers', 'PB']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
PBs = list(df2['PB'].astype('int'))
|
||||
return date, nums, PBs
|
||||
|
||||
date, nums, PBs = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
||||
# so the old records have some numbers that dont exist in the game anymore
|
||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 69]
|
||||
PBs = [x for x in PBs if 1 <= x <= 26]
|
||||
|
||||
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(PBs).most_common(1)
|
||||
PB = [v[0] for v in most_common_pb]
|
||||
frequency_pb = [v[-1] for v in most_common_pb]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = 1 / every possible ticket, 69 choose 5 white balls times 26 powerballs = 292201338
|
||||
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
|
||||
Chance = frac(1, comb(69, 5) * 26)
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} PB: {PB}\n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast', 'PB', 'Chance')))
|
||||
h = 'Forecast', 'PB', 'Chance'
|
||||
f = open('pb_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
@@ -1,80 +0,0 @@
|
||||
# WVLottopy megamil: Matteo DiBiagio
|
||||
from fractions import Fraction as frac
|
||||
from math import comb
|
||||
import pandas as pd
|
||||
import requests
|
||||
from collections import Counter
|
||||
import csv
|
||||
|
||||
|
||||
def get_data():
|
||||
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
|
||||
df_old = pd.read_excel('./excel_lotto_records/lotto_megamil.xlsx')
|
||||
salvaged = df_old[['Date', 'Numbers', 'MB']]
|
||||
|
||||
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=20&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||
header = {
|
||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
|
||||
}
|
||||
# Get web data, the new site pulls past draws from json 500 at a time
|
||||
web = {'Date': [], 'Numbers': [], 'MB': []}
|
||||
page = 0
|
||||
while True:
|
||||
r = requests.get(url + str(page), headers=header)
|
||||
data = r.json()
|
||||
for x in data['content']:
|
||||
web['Date'].append(x['drawingDate'])
|
||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||
web['MB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||
if data['last']:
|
||||
break
|
||||
page += 1
|
||||
dfs = [pd.DataFrame(web)]
|
||||
pd.set_option('display.max_rows', None)
|
||||
# Specifies no max rows, otherwise only shows 10 records
|
||||
df = pd.concat([dfs[0], salvaged], ignore_index=True)
|
||||
df2 = df[['Date', 'Numbers', 'MB']]
|
||||
date = list(df2['Date'])
|
||||
nums = list(df2['Numbers'].astype('str'))
|
||||
MBs = list(df2['MB'].astype('int'))
|
||||
return date, nums, MBs
|
||||
|
||||
date, nums, MBs = get_data()
|
||||
|
||||
# Formatting
|
||||
# Site numbers come split by – and the excel records by - so it splits on both
|
||||
hyphenfree = []
|
||||
for x in nums:
|
||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||
splitlist = ", ".join(hyphenfree)
|
||||
sep = splitlist.split(", ")
|
||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
||||
# so the old records have some numbers that dont exist in the game anymore
|
||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 70]
|
||||
MBs = [x for x in MBs if 1 <= x <= 24]
|
||||
|
||||
for n in range(0, 70):
|
||||
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, 25):
|
||||
most_common_mb = Counter(MBs).most_common(1)
|
||||
MB = [v[0] for v in most_common_mb]
|
||||
frequency_mb = [v[-1] for v in most_common_mb]
|
||||
|
||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||
# Chance = 1 / every possible ticket, 70 choose 5 white balls times 24 mega balls = 290472336
|
||||
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
|
||||
Chance = frac(1, comb(70, 5) * 24)
|
||||
Forecast = str(" - ".join(sorted_nums))
|
||||
|
||||
#print(f"Likely numbers are . . . {Forecast} MB: {MB}\n"
|
||||
#f"With percent chance of winning being {Chance}")
|
||||
|
||||
d = dict(((k, eval (k)) for k in ('Forecast', 'MB', 'Chance')))
|
||||
h = 'Forecast', 'MB', 'Chance'
|
||||
f = open('mm_ans.csv', 'w', encoding='utf_8')
|
||||
writer = csv.DictWriter(f, fieldnames=h)
|
||||
writer.writeheader()
|
||||
writer.writerow(d)
|
||||
@@ -1,2 +0,0 @@
|
||||
Forecast,MB,Chance
|
||||
10 - 11 - 17 - 20 - 31,[7],1/290472336
|
||||
|
@@ -1,2 +0,0 @@
|
||||
Forecast,PB,Chance
|
||||
16 - 23 - 27 - 28 - 32,[20],1/292201338
|
||||
|
@@ -1,2 +0,0 @@
|
||||
pandas==1.3.5
|
||||
requests==2.26.0
|
||||
@@ -1 +0,0 @@
|
||||
echo "Powerball" && python lottopy_pb.py && echo "MegaMillions" && python megamil.py && echo "Lotto America" && python lotto_america.py && echo "Daily3" && python daily3.py && echo "Daily4" && python daily4.py && echo "Cash25" && python cash25.py && echo "Cash Pop" && python cashpop.py
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user