Example #1
0
 def indices(self):
     if len(self.groupings) == 1:
         return self.primary.indices
     else:
         to_groupby = zip(*(ping.grouper for ping in self.groupings))
         to_groupby = Index(to_groupby)
         return lib.groupby_indices(to_groupby)
Example #2
0
 def indices(self):
     if len(self.groupings) == 1:
         return self.primary.indices
     else:
         to_groupby = zip(*(ping.grouper for ping in self.groupings))
         to_groupby = Index(to_groupby)
         return lib.groupby_indices(to_groupby)
Example #3
0
def algo2():
    unique_labels = np.unique(labels)
    indices = lib.groupby_indices(labels)
    result = np.empty(len(unique_labels))

    for i, label in enumerate(unique_labels):
        result[i] = data.take(indices[label]).sum()
Example #4
0
def algo2():
    unique_labels = np.unique(labels)
    indices = lib.groupby_indices(labels)
    result = np.empty(len(unique_labels))

    for i, label in enumerate(unique_labels):
        result[i] = data.take(indices[label]).sum()
Example #5
0
 def indices(self):
     if len(self.groupings) == 1:
         return self.primary.indices
     else:
         # TODO: this is massively inefficient
         to_groupby = zip(*(ping.grouper for ping in self.groupings))
         to_groupby = Index(to_groupby)
         return lib.groupby_indices(to_groupby)
Example #6
0
    def __init__(self, index, grouper=None, name=None, level=None):
        self.name = name
        self.level = level
        self.grouper = _convert_grouper(index, grouper)

        if level is not None:
            inds = index.labels[level]
            labels = index.levels[level].values.take(inds)

            if grouper is not None:
                self.grouper = _tseries.arrmap(labels, self.grouper)
            else:
                self.grouper = labels

        self.index = index.values

        # no level passed
        if not isinstance(self.grouper, np.ndarray):
            self.grouper = _tseries.arrmap(self.index, self.grouper)

        self.indices = _tseries.groupby_indices(self.grouper)
Example #7
0
def _groupby_indices(values):
    if values.dtype != np.object_:
        values = values.astype('O')
    return lib.groupby_indices(values)
Example #8
0
 def indices(self):
     return lib.groupby_indices(self.grouper)
Example #9
0
 def indices(self):
     return lib.groupby_indices(self.grouper)
Example #10
0
 def indices(self):
     return _tseries.groupby_indices(self.grouper)