This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mongoimport --type=csv --headerline -d nfl -c pbp_2015 pbp-2015.csv | |
2016-01-26T21:40:44.549-0500 Failed: fields cannot be identical: '' and '' | |
2016-01-26T21:40:44.549-0500 imported 0 documents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i = 0; i < 100000; i++) { | |
match = {"$match": | |
{ | |
"OffenseTeam": "DEN", | |
"$or": [{"PlayType": "PASS"}, {"PlayType": "RUSH"}], | |
"IsNoPlay": 0 | |
} | |
} | |
sample = {"$sample": | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
import dateutil.parser | |
import pymongo | |
import sys | |
if len(sys.argv) != 2: | |
print("usage: %s csvfile" % sys.argv[0]) | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
match = {"$match": | |
{ | |
"OffenseTeam": "DEN", | |
"$or": [{"PlayType": "PASS"}, {"PlayType": "RUSH"}], | |
"IsNoPlay": 0 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sample = {"$sample": | |
{ | |
"size": 60 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proj = {"$project": | |
{ | |
"team": "$OffenseTeam", | |
"yards": "$Yards", | |
"turnovers": {"$sum": ["$IsInterception", "$IsFumble"]} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group = {"$group": | |
{ | |
"_id": "$team", | |
"yards": {"$sum": "$yards"}, | |
"turnovers": {"$sum": "$turnovers"} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.pbp_2015_simulations.find({"i": 0}) | |
{ | |
"_id": ObjectId("56a7e1bc87776355710ff107"), | |
"yards": 479, | |
"turnovers": 2, | |
"team": "DEN", | |
"i": 0 | |
} | |
{ | |
"_id": ObjectId("56a7e1bc87776355710ff108"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proj0 = {"$project": | |
{ | |
"i": 1, | |
"DEN_score": {"$sum": {"$cond": [{"$eq": ["$team", "DEN"]}, {"$multiply": [{"$subtract": [{"$divide": ["$yards", 80]}, "$turnovers"]}, 7]}, 0]}}, | |
"CAR_score": {"$sum": {"$cond": [{"$eq": ["$team", "CAR"]}, {"$multiply": [{"$subtract": [{"$divide": ["$yards", 80]}, "$turnovers"]}, 7]}, 0]}} | |
} | |
} | |
group0 = {"$group": | |
{ | |
"_id": "$i", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"waitedMS": NumberLong("0"), | |
"result": [ | |
{ | |
"_id": 1, | |
"DEN_avg_score": 28.743076249999753, | |
"DEN_avg_score_std": 9.011384256852498, | |
"DEN_win_pct": 0.58883, | |
"SEA_avg_score": 25.868169249999788, | |
"SEA_avg_score_std": 9.032120640996355, |
OlderNewer