def test_md56b4698269dd34a823cf6b233c6165614(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 17)]) assert all(x in list( Rechash.RecHash().md56b4698269dd34a823cf6b233c6165614(empty)) for x in finalcols)
def test_md57f97f3885d50fcf9b92797810856a89f(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 21)]) assert all(x in list( Rechash.RecHash().md57f97f3885d50fcf9b92797810856a89f(empty)) for x in finalcols)
def test_md5bfbf86ae0485a0a70692ae04124449b9(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 18)]) assert all(x in list( Rechash.RecHash().md5bfbf86ae0485a0a70692ae04124449b9(empty)) for x in finalcols)
def finalcols(): return Rechash.RecHash().base[1:] + Rechash.RecHash().receiving + Rechash.RecHash().rushing + \ Rechash.RecHash().kick_rt + Rechash.RecHash().punt_rt + Rechash.RecHash().scoring2p + \ Rechash.RecHash().scoring
def test_md5111e8480632f73642d7e20acbdbe6b16(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 25)]) assert all(x in list( Rechash.RecHash().md5111e8480632f73642d7e20acbdbe6b16(empty)) for x in finalcols)
def test_md5adc05c5af0f88775d3605d02c831c0ed(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 20)]) assert all(x in list( Rechash.RecHash().md5adc05c5af0f88775d3605d02c831c0ed(empty)) for x in finalcols)
def test_md550fcceaa170b1a1e501e3f40548e403d(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 29)]) assert all(x in list( Rechash.RecHash().md550fcceaa170b1a1e501e3f40548e403d(empty)) for x in finalcols)
def test_md552589e869a13d76c6d0dbf066cab536f(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 18)]) assert all(x in list( Rechash.RecHash().md552589e869a13d76c6d0dbf066cab536f(empty)) for x in finalcols)
def test_md54c82a489ec5b2c943e78c9018dcbbca1(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 36)]) assert all(x in list( Rechash.RecHash().md54c82a489ec5b2c943e78c9018dcbbca1(empty)) for x in finalcols)
def test_md5e8ffc7202223bb253e92da83b76e9944(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 39)]) assert all(x in list( Rechash.RecHash().md5e8ffc7202223bb253e92da83b76e9944(empty)) for x in finalcols)
def test_md54560c290b45e942c16cc6d7811345fce(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 37)]) assert all(x in list( Rechash.RecHash().md54560c290b45e942c16cc6d7811345fce(empty)) for x in finalcols)
def test_md5bcb96297b50fb2120f475e8e05fbabcd(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 41)]) assert all(x in list( Rechash.RecHash().md5bcb96297b50fb2120f475e8e05fbabcd(empty)) for x in finalcols)
def test_md5b3c4237d9a10de8cfaad61852cb552c4(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 32)]) assert all(x in list( Rechash.RecHash().md5b3c4237d9a10de8cfaad61852cb552c4(empty)) for x in finalcols)
def test_md5aa321161d6f3f5230259dbc4ae67299a(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 24)]) assert all(x in list( Rechash.RecHash().md5aa321161d6f3f5230259dbc4ae67299a(empty)) for x in finalcols)
def test_md5e160e714b29305ecfecf513cbf84b80f(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 25)]) assert all(x in list( Rechash.RecHash().md5e160e714b29305ecfecf513cbf84b80f(empty)) for x in finalcols)
def receiving(self, player_link, year, **kwargs): # Set up the gamelog suffix gamelog_suffix = '/gamelog/%s/' % year # Modify the player url to point to the gamelog log_url = player_link[:-4] + gamelog_suffix # Get html html = Loader.Loader().load_page(log_url).content.decode() # ************** generate general stats, these need to be combined later ****************** gen = PlayerParser.PlayerParser().parse_general_info(html) # parse tables w pandas df = pd.read_html(html)[0] # hash the columns to determine which fields are being used which_cols = hashlib.md5(json.dumps(list(df.columns.levels[0])).encode()).hexdigest() # Here we make a dict of hashes and their corresponding column parser, this is faster than if/else options = { "b3c4237d9a10de8cfaad61852cb552c4": Rechash.RecHash().md5b3c4237d9a10de8cfaad61852cb552c4, "bcb96297b50fb2120f475e8e05fbabcd": Rechash.RecHash().md5bcb96297b50fb2120f475e8e05fbabcd, "4560c290b45e942c16cc6d7811345fce": Rechash.RecHash().md54560c290b45e942c16cc6d7811345fce, "4c82a489ec5b2c943e78c9018dcbbca1": Rechash.RecHash().md54c82a489ec5b2c943e78c9018dcbbca1, "e8ffc7202223bb253e92da83b76e9944": Rechash.RecHash().md5e8ffc7202223bb253e92da83b76e9944, "50fcceaa170b1a1e501e3f40548e403d": Rechash.RecHash().md550fcceaa170b1a1e501e3f40548e403d, "e160e714b29305ecfecf513cbf84b80f": Rechash.RecHash().md5e160e714b29305ecfecf513cbf84b80f, "111e8480632f73642d7e20acbdbe6b16": Rechash.RecHash().md5111e8480632f73642d7e20acbdbe6b16, "adc05c5af0f88775d3605d02c831c0ed": Rechash.RecHash().md5adc05c5af0f88775d3605d02c831c0ed, "bfbf86ae0485a0a70692ae04124449b9": Rechash.RecHash().md5bfbf86ae0485a0a70692ae04124449b9, "6b4698269dd34a823cf6b233c6165614": Rechash.RecHash().md56b4698269dd34a823cf6b233c6165614, "7f97f3885d50fcf9b92797810856a89f": Rechash.RecHash().md57f97f3885d50fcf9b92797810856a89f, "aa321161d6f3f5230259dbc4ae67299a": Rechash.RecHash().md5aa321161d6f3f5230259dbc4ae67299a, "1193d47266d4acdcf1b6fca165121100": Rechash.RecHash().md51193d47266d4acdcf1b6fca165121100, "52589e869a13d76c6d0dbf066cab536f": Rechash.RecHash().md552589e869a13d76c6d0dbf066cab536f, "d522b9357244c20714a3b21f8f404918": Rechash.RecHash().md5d522b9357244c20714a3b21f8f404918} df = options[which_cols](df) # send df to the common parser df = self.common(df, year) # Add the name df.loc[:, 'Name'] = gen['name'] # Add the players position df.loc[:, 'Pos'] = gen['position'] df['Throws'] = gen['throws'] df['Height'] = gen['height'] df['Weight'] = gen['weight'] df['DOB_mo'] = gen['bday_mo'] df['DOB_day'] = gen['bday_day'] df['DOB_yr'] = gen['bday_yr'] df['College'] = gen['college'] df = df[['Name', 'Pos', 'Height', 'Weight', 'DOB_mo', 'DOB_day', 'DOB_yr', 'College'] + Rechash.RecHash().base[1:] + ['PF', 'PA'] + Rechash.RecHash().receiving + Rechash.RecHash().rushing + Rechash.RecHash().kick_rt + Rechash.RecHash().punt_rt + Rechash.RecHash().scoring2p + Rechash.RecHash().scoring] return df
def test_md51193d47266d4acdcf1b6fca165121100(self, finalcols): # generate empty df with cols of length that the site would return in this instance empty = pd.DataFrame(columns=[x for x in range(0, 43)]) assert all(x in list( Rechash.RecHash().md51193d47266d4acdcf1b6fca165121100(empty)) for x in finalcols)