comment cleanup, put the windows line endings back and added the 2021 draws that were missing from the excel
This commit is contained in:
1 parent
d634159947
commit
f4c4ee616d
11 files changed
+451
-467
No files matched your search
@@ -1,65 +1,62 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from math import comb
|
from math import comb
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/cash25.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/cash25.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=10&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': []}
|
web = {'Date': [], 'Numbers': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/cash25.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/cash25.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers']]
|
df2 = df[['Date', 'Numbers']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
return date, nums
|
return date, nums
|
||||||
|
|
||||||
date, nums = get_data()
|
date, nums = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
# ball range changed over the years so drop numbers that arent in the game anymore
|
||||||
# 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]
|
||||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 25]
|
|
||||||
|
for n in range(0, 25):
|
||||||
for n in range(0, 25):
|
most_common= Counter(sep).most_common(6)
|
||||||
most_common= Counter(sep).most_common(6)
|
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]
|
|
||||||
|
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
Chance = frac(1, comb(25, 6)) # Chance = 1 / all possible tickets i.e. 177100
|
||||||
# Chance = 1 / every possible ticket, 25 choose 6 = 177100
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
|
|
||||||
Chance = frac(1, comb(25, 6))
|
print(f"Likely numbers are . . . {Forecast} \n"
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
print(f"Likely numbers are . . . {Forecast} \n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
+56
-56
@@ -1,56 +1,56 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=24&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, cash pop draws every 15 min so only use the last ~3000 draws (about a month)
|
# Get web data, cash pop is drawn every 15 min so ~3000 draws is about a month
|
||||||
web = {'Date': [], 'Numbers': []}
|
web = {'Date': [], 'Numbers': []}
|
||||||
ids, times = [], []
|
ids, times = [], []
|
||||||
page = 0
|
page = 0
|
||||||
while page < 6:
|
while page < 6:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||||
ids.append(x['externalId'])
|
ids.append(x['externalId'])
|
||||||
times.append(x['drawDate'])
|
times.append(x['drawDate'])
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
df2 = pd.DataFrame(web)
|
df2 = pd.DataFrame(web)
|
||||||
# The site only keeps a year of cash pop draws, keep our own record of every draw
|
# site only keeps a year of cash pop, keep our own record
|
||||||
records.merge_save('./excel_lotto_records/cash_pop.xlsx', df2, ids=ids, times=times)
|
records.merge_save('./excel_lotto_records/cash_pop.xlsx', df2, ids=ids, times=times)
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
return date, nums
|
return date, nums
|
||||||
|
|
||||||
date, nums = get_data()
|
date, nums = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', '))
|
hyphenfree.append(x.replace('–',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only keep 1 - 15, just in case anything weird comes back from the site
|
# only 1 - 15
|
||||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 15]
|
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 15]
|
||||||
|
|
||||||
for n in range(0, 15):
|
for n in range(0, 15):
|
||||||
most_common= Counter(sep).most_common(3)
|
most_common= Counter(sep).most_common(3)
|
||||||
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]
|
||||||
|
|
||||||
Forecast = likely_nums[0]
|
Forecast = likely_nums[0]
|
||||||
Backups = str(" - ".join(likely_nums[1:]))
|
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
|
Chance = frac(1, 15) # one number out of 15
|
||||||
|
|
||||||
print(f"Likely number is . . . {Forecast} Backups: {Backups}\n"
|
print(f"Likely number is . . . {Forecast} Backups: {Backups}\n"
|
||||||
f"With percent chance of winning being {Chance}")
|
f"With percent chance of winning being {Chance}")
|
||||||
@@ -1,63 +1,61 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/daily3.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/daily3.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=9&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': []}
|
web = {'Date': [], 'Numbers': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/daily3.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/daily3.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers']]
|
df2 = df[['Date', 'Numbers']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
return date, nums
|
return date, nums
|
||||||
|
|
||||||
date, nums = get_data()
|
date, nums = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only keep actual digits, gets rid of any blanks from the excel records
|
# gets rid of blanks from the excel
|
||||||
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
||||||
|
|
||||||
for n in range(0, 10):
|
for n in range(0, 10):
|
||||||
most_common= Counter(sep).most_common(3)
|
most_common= Counter(sep).most_common(3)
|
||||||
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]
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
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
|
Chance = frac(6, 1000) # box play, 6 ways out of 1000 (straight is 1/1000)
|
||||||
# playing it straight (exact order) is 1/1000
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
Chance = frac(6, 1000)
|
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
print(f"Likely numbers are . . . {Forecast} \n"
|
||||||
|
f"With percent chance of winning being {Chance}")
|
||||||
print(f"Likely numbers are . . . {Forecast} \n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
@@ -1,63 +1,61 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/daily4.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/daily4.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=14&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': []}
|
web = {'Date': [], 'Numbers': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/daily4.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/daily4.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers']]
|
df2 = df[['Date', 'Numbers']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
return date, nums
|
return date, nums
|
||||||
|
|
||||||
date, nums = get_data()
|
date, nums = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only keep actual digits, gets rid of any blanks from the excel records
|
# gets rid of blanks from the excel
|
||||||
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
|
||||||
|
|
||||||
for n in range(0, 9):
|
for n in range(0, 9):
|
||||||
most_common= Counter(sep).most_common(4)
|
most_common= Counter(sep).most_common(4)
|
||||||
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]
|
||||||
|
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
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
|
Chance = frac(24, 10000) # box play, 24 ways out of 10000 (straight is 1/10000)
|
||||||
# playing it straight (exact order) is 1/10000
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
Chance = frac(24, 10000)
|
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
print(f"Likely numbers are . . . {Forecast} \n"
|
||||||
|
f"With percent chance of winning being {Chance}")
|
||||||
print(f"Likely numbers are . . . {Forecast} \n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+70
-73
@@ -1,73 +1,70 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from math import comb
|
from math import comb
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers', 'SB']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=16&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': [], 'SB': []}
|
web = {'Date': [], 'Numbers': [], 'SB': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
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])
|
web['SB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/lotto_america.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/lotto_america.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers', 'SB']]
|
df2 = df[['Date', 'Numbers', 'SB']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
SBs = list(df2['SB'].astype('int'))
|
SBs = list(df2['SB'].astype('int'))
|
||||||
return date, nums, SBs
|
return date, nums, SBs
|
||||||
|
|
||||||
date, nums, SBs = get_data()
|
date, nums, SBs = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
# ball range changed over the years so drop numbers that arent in the game anymore
|
||||||
# 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]
|
||||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 52]
|
SBs = [x for x in SBs if 1 <= x <= 10]
|
||||||
SBs = [x for x in SBs if 1 <= x <= 10]
|
|
||||||
|
for n in range(0, 52):
|
||||||
for n in range(0, 52):
|
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]
|
|
||||||
|
for n in range(0, 10):
|
||||||
for n in range(0, 10):
|
most_common_sb = Counter(SBs).most_common(1)
|
||||||
most_common_sb = Counter(SBs).most_common(1)
|
SB = [v[0] for v in most_common_sb]
|
||||||
SB = [v[0] for v in most_common_sb]
|
frequency_sb = [v[-1] 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))
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
Chance = frac(1, comb(52, 5) * 10) # Chance = 1 / all possible tickets i.e. 25989600
|
||||||
# Chance = 1 / every possible ticket, 52 choose 5 white balls times 10 star balls = 25989600
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
# 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)
|
print(f"Likely numbers are . . . {Forecast} SB: {SB}\n"
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
print(f"Likely numbers are . . . {Forecast} SB: {SB}\n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
+70
-73
@@ -1,73 +1,70 @@
|
|||||||
# WVLottopy: Matteo DiBiagio
|
# WVLottopy: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from math import comb
|
from math import comb
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/lotto.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/lotto.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers', 'PB']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=12&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': [], 'PB': []}
|
web = {'Date': [], 'Numbers': [], 'PB': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
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])
|
web['PB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/lotto.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/lotto.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers', 'PB']]
|
df2 = df[['Date', 'Numbers', 'PB']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
PBs = list(df2['PB'].astype('int'))
|
PBs = list(df2['PB'].astype('int'))
|
||||||
return date, nums, PBs
|
return date, nums, PBs
|
||||||
|
|
||||||
date, nums, PBs = get_data()
|
date, nums, PBs = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
# ball range changed over the years so drop numbers that arent in the game anymore
|
||||||
# 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]
|
||||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 69]
|
PBs = [x for x in PBs if 1 <= x <= 26]
|
||||||
PBs = [x for x in PBs if 1 <= x <= 26]
|
|
||||||
|
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]
|
|
||||||
|
for n in range(0, 26):
|
||||||
for n in range(0, 26):
|
most_common_pb = Counter(PBs).most_common(1)
|
||||||
most_common_pb = Counter(PBs).most_common(1)
|
PB = [v[0] for v in most_common_pb]
|
||||||
PB = [v[0] for v in most_common_pb]
|
frequency_pb = [v[-1] 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))
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
Chance = frac(1, comb(69, 5) * 26) # Chance = 1 / all possible tickets i.e. 292201338
|
||||||
# Chance = 1 / every possible ticket, 69 choose 5 white balls times 26 powerballs = 292201338
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
# 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)
|
print(f"Likely numbers are . . . {Forecast} PB: {PB}\n"
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
print(f"Likely numbers are . . . {Forecast} PB: {PB}\n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
+71
-74
@@ -1,74 +1,71 @@
|
|||||||
# WVLottopy megamil: Matteo DiBiagio
|
# WVLottopy megamil: Matteo DiBiagio
|
||||||
from fractions import Fraction as frac
|
from fractions import Fraction as frac
|
||||||
from math import comb
|
from math import comb
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import records
|
import records
|
||||||
import requests
|
import requests
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
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
|
# previous records which have since been removed from wvlottery.com's database
|
||||||
df_old = pd.read_excel('./excel_lotto_records/lotto_megamil.xlsx')
|
df_old = pd.read_excel('./excel_lotto_records/lotto_megamil.xlsx')
|
||||||
salvaged = df_old[['Date', 'Numbers', 'MB']]
|
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='
|
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=20&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
|
||||||
header = {
|
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",
|
||||||
}
|
}
|
||||||
# Get web data, the new site pulls past draws from json 500 at a time
|
# Get web data, 500 draws a page
|
||||||
web = {'Date': [], 'Numbers': [], 'MB': []}
|
web = {'Date': [], 'Numbers': [], 'MB': []}
|
||||||
page = 0
|
page = 0
|
||||||
while True:
|
while True:
|
||||||
r = requests.get(url + str(page), headers=header)
|
r = requests.get(url + str(page), headers=header)
|
||||||
data = r.json()
|
data = r.json()
|
||||||
for x in data['content']:
|
for x in data['content']:
|
||||||
web['Date'].append(records.draw_day(x))
|
web['Date'].append(records.draw_day(x))
|
||||||
web['Numbers'].append('–'.join(str(n['data']) for n in x['resultData'] if n['type'] == 'REGULAR'))
|
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])
|
web['MB'].append([n['data'] for n in x['resultData'] if n['type'] == 'SPECIAL'][0])
|
||||||
if data['last']:
|
if data['last']:
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
dfs = [pd.DataFrame(web)]
|
dfs = [pd.DataFrame(web)]
|
||||||
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
|
||||||
# Adds any draw not in the sheet yet, so the excel record keeps growing
|
# adds new draws to the excel so the records keep growing
|
||||||
df = records.merge_save('./excel_lotto_records/lotto_megamil.xlsx', dfs[0], fallback=salvaged)
|
df = records.merge_save('./excel_lotto_records/lotto_megamil.xlsx', dfs[0], fallback=salvaged)
|
||||||
df2 = df[['Date', 'Numbers', 'MB']]
|
df2 = df[['Date', 'Numbers', 'MB']]
|
||||||
date = list(df2['Date'])
|
date = list(df2['Date'])
|
||||||
nums = list(df2['Numbers'].astype('str'))
|
nums = list(df2['Numbers'].astype('str'))
|
||||||
MBs = list(df2['MB'].astype('int'))
|
MBs = list(df2['MB'].astype('int'))
|
||||||
return date, nums, MBs
|
return date, nums, MBs
|
||||||
|
|
||||||
date, nums, MBs = get_data()
|
date, nums, MBs = get_data()
|
||||||
|
|
||||||
# Formatting
|
# Formatting
|
||||||
# Site numbers come split by – and the excel records by - so it splits on both
|
# site uses – and the excel uses -
|
||||||
hyphenfree = []
|
hyphenfree = []
|
||||||
for x in nums:
|
for x in nums:
|
||||||
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
hyphenfree.append(x.replace('–',', ').replace('-',', '))
|
||||||
splitlist = ", ".join(hyphenfree)
|
splitlist = ", ".join(hyphenfree)
|
||||||
sep = splitlist.split(", ")
|
sep = splitlist.split(", ")
|
||||||
# Only count numbers that can still be called, the ball ranges have changed over the years
|
# ball range changed over the years so drop numbers that arent in the game anymore
|
||||||
# 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]
|
||||||
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 70]
|
MBs = [x for x in MBs if 1 <= x <= 24]
|
||||||
MBs = [x for x in MBs if 1 <= x <= 24]
|
|
||||||
|
for n in range(0, 70):
|
||||||
for n in range(0, 70):
|
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]
|
|
||||||
|
for n in range(0, 25):
|
||||||
for n in range(0, 25):
|
most_common_mb = Counter(MBs).most_common(1)
|
||||||
most_common_mb = Counter(MBs).most_common(1)
|
MB = [v[0] for v in most_common_mb]
|
||||||
MB = [v[0] for v in most_common_mb]
|
frequency_mb = [v[-1] 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))
|
||||||
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
|
Chance = frac(1, comb(70, 5) * 24) # Chance = 1 / all possible tickets i.e. 290472336
|
||||||
# Chance = 1 / every possible ticket, 70 choose 5 white balls times 24 mega balls = 290472336
|
Forecast = str(" - ".join(sorted_nums))
|
||||||
# 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)
|
print(f"Likely numbers are . . . {Forecast} MB: {MB}\n"
|
||||||
Forecast = str(" - ".join(sorted_nums))
|
f"With percent chance of winning being {Chance}")
|
||||||
|
|
||||||
print(f"Likely numbers are . . . {Forecast} MB: {MB}\n"
|
|
||||||
f"With percent chance of winning being {Chance}")
|
|
||||||
Reference in new issue
Block a user