-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.py
More file actions
25 lines (20 loc) · 686 Bytes
/
query.py
File metadata and controls
25 lines (20 loc) · 686 Bytes
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
import pandas as pd
from pymongo import MongoClient
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
client = MongoClient('mongodb://localhost:27017')
db = client['final_project']
games_collection = db['games']
teams_collection = db['teams']
events_collection = db['events']
def get_teams(game_id):
query = {'game_id': game_id}
cursor = teams_collection.find(query)
return pd.DataFrame(list(cursor))
def get_games():
cursor = games_collection.find({})
return pd.DataFrame(list(cursor))
def get_events(game_id):
query = {'game_id': game_id}
cursor = events_collection.find(query)
return pd.DataFrame(list(cursor))