forked from slxmmy999/InfiniteBaseballGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_analysis.py
27 lines (22 loc) · 1.11 KB
/
data_analysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from server.Database import Database
from pymongo import MongoClient
class DataAnalysis:
def __init__(self):
self.db: Database = Database(MongoClient("mongodb+srv://samcoan100:[email protected]/?retryWrites=true&w=majority"), False)
@staticmethod
def pick_frequency(player_name, players):
try:
return players[player_name]['pick_frequency']
except KeyError:
return 10 # or another value that makes sense in your context
def get_top_and_bottom(self):
# Get the entire matchup collection and find the most picked and least picked answer for each document
matchups = self.db.collection.find()
with open("full_data.txt", "w") as file:
for matchup in matchups:
file.write(f"{Database.unnormalize_team_names(matchup['team_combination'])}\n")
for player in matchup['players']:
file.write(f"{player} | {self.pick_frequency(player, matchup['players'])}\n")
file.write("\n")
da = DataAnalysis()
da.get_top_and_bottom()