sportsref/nba/players.py
def age(self, year, month=2, day=1):
        """Returns the age of the player on a given date.

        :year: int representing the year.
        :month: int representing the month (1-12).
        :day: int representing the day within the month (1-31).
        :returns: Age in years as a float.
        """
        doc = self.get_main_doc()
        date_string = doc('span[itemprop="birthDate"]').attr('data-birth')
        regex = r'(\d{4})\-(\d{2})\-(\d{2})'
        date_args = map(int, re.match(regex, date_string).groups())
        birth_date = datetime.date(*date_args)
        age_date = datetime.date(year=year, month=month, day=day)
        delta = age_date - birth_date
        age = delta.days / 365.
        return age
def age(self, year, month=2, day=1):
        doc = self.get_main_doc()
        date_string = doc('span[itemprop="birthDate"]').attr('data-birth')
        regex = r'(\d{4})\-(\d{2})\-(\d{2})'
        date_args = map(int, re.match(regex, date_string).groups())
        birth_date = datetime.date(*date_args)
        age_date = datetime.date(year=year, month=month, day=day)
        delta = age_date - birth_date
        age = delta.days / 365.
        return age
def age ( self , year , month = 2 , day = 1 ) : doc = self . get_main_doc ( ) date_string = doc ( 'span[itemprop="birthDate"]' ) . attr ( 'data-birth' ) regex = r'(\d{4})\-(\d{2})\-(\d{2})' date_args = map ( int , re . match ( regex , date_string ) . groups ( ) ) birth_date = datetime . date ( * date_args ) age_date = datetime . date ( year = year , month = month , day = day ) delta = age_date - birth_date age = delta . days / 365. return age
Returns the age of the player on a given date.

        :year: int representing the year.
        :month: int representing the month (1-12).
        :day: int representing the day within the month (1-31).
        :returns: Age in years as a float.
Returns the age of the player on a given date .