Exemple #1
0
 def partition_by_team(self):
     # get the unique teams in this current data frame
     teams = self.historical_data["standardHomeTeamName"].unique()
     teams = numpy_sort(teams)
     games_by_team = {team: [] for team in teams}
     # for each team setup an empty collection
     for team in teams:
         by_home_team = self.historical_data[
             self.historical_data["standardHomeTeamName"].isin([team])]
         by_away_team = self.historical_data[
             self.historical_data["standardAwayTeamName"].isin([team])]
         by_team = pd.concat([by_home_team, by_away_team])
         games_by_team[team] = by_team
     return games_by_team
Exemple #2
0
def idealfourths(data, axis=None):
    """This function returns an estimate of the lower and upper quartiles of the data along
    the given axis, as computed with the ideal fourths. This function was taken
    from scipy.stats.mstat_extra.py (http://projects.scipy.org/scipy/browser/trunk/scipy/stats/mstats_extras.py?rev=6392)
    """
    def _idf(data):
        x = data.compressed()
        n = len(x)
        if n < 3:
            return [numpy_nan,numpy_nan]
        (j,h) = divmod(n/4. + 5/12.,1)
        qlo = (1-h)*x[j-1] + h*x[j]
        k = n - j
        qup = (1-h)*x[k] + h*x[k-1]
        return [qlo, qup]
    data = numpy_sort(data, axis=axis).view(MaskedArray)
    if (axis is None):
        return _idf(data)
    else:
        return apply_along_axis(_idf, axis, data)
Exemple #3
0
def idealfourths(data, axis=None):
    """This function returns an estimate of the lower and upper quartiles of the data along
    the given axis, as computed with the ideal fourths. This function was taken
    from scipy.stats.mstat_extra.py (http://projects.scipy.org/scipy/browser/trunk/scipy/stats/mstats_extras.py?rev=6392)
    """
    def _idf(data):
        x = data.compressed()
        n = len(x)
        if n < 3:
            return [numpy_nan, numpy_nan]
        (j, h) = divmod(n / 4. + 5 / 12., 1)
        qlo = (1 - h) * x[j - 1] + h * x[j]
        k = n - j
        qup = (1 - h) * x[k] + h * x[k - 1]
        return [qlo, qup]

    data = numpy_sort(data, axis=axis).view(MaskedArray)
    if (axis is None):
        return _idf(data)
    else:
        return apply_along_axis(_idf, axis, data)