formatting changes

This commit is contained in:
matteo-id committed 2022-05-23 19:33:13 -04:00
1 parent a0c172d11f
commit 283e893438
18 files changed
+83 -56

No files matched your search

@@ -1,4 +1,5 @@
# WVLottopy: Matteo DiBiagio
#from django_lottopy.lottopy_site.lottopy.lottopy_web_edition.megamil import Winning_Numbers
from sheet2dict import Worksheet
import pandas as pd
import requests
@@ -23,7 +24,7 @@ df2 = df[['Date', 'Numbers', 'SB', 'All Star']]
#print(df2)
# To excel file
df2.to_excel('../lottopy/lotto_america.xlsx')
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)
@@ -31,7 +32,7 @@ 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'))
PB = list(df['SB'].astype('int'))
PBs = list(df['SB'].astype('int'))
#appearances = list(df2['Winners WV Only'].astype('int'))
# Index for each row
@@ -53,7 +54,7 @@ ws.xlsx_to_dict(path='lotto_america.xlsx', select_sheet='Sheet1')
# Formatting
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('-',', '))
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
@@ -63,15 +64,20 @@ for n in range(0, 52):
frequency = [v[-1] for v in most_common]
for n in range(0, 10):
most_common_pb = Counter(PB).most_common(1)
likely_pb = [v[0] for v in most_common_pb]
most_common_pb = Counter(PBs).most_common(1)
SB = [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 / 25989600) * 100] # Chance = number call freq / all possible numbers i.e. 11238513
Chance = [(total_freq / 25989600) * 100] # Chance = number call freq / all possible numbers i.e. 11238513
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, "%")
f = open('la_ans.csv', 'w')
writer = csv.writer(f)
writer.writerow(sorted_nums + likely_pb + chance)
d = dict(((k, eval (k)) for k in ('Winning_Numbers', 'SB', 'Chance')))
h = 'Winning_Numbers', 'SB', 'Chance'
f = open('la_ans.csv', 'w', encoding='utf_8')
writer = csv.DictWriter(f, fieldnames=h)
writer.writeheader()
writer.writerow(d)