How to use the streamz.dataframe.core.Window function in streamz

To help you get started, we’ve selected a few streamz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-streamz / streamz / streamz / dataframe / core.py View on Github external
def reset_index(self):
        return Window(self.root.reset_index(), n=self.n, value=self.value)
github python-streamz / streamz / streamz / dataframe / core.py View on Github external
def map_partitions(self, func, *args, **kwargs):
        args2 = [a.root if isinstance(a, Window) else a for a in args]
        root = self.root.map_partitions(func, *args2, **kwargs)
        return Window(root, n=self.n, value=self.value)
github python-streamz / streamz / streamz / dataframe / core.py View on Github external
def __getitem__(self, key):
        sdf = self.root[key]
        return Window(sdf, n=self.n, value=self.value)
github python-streamz / streamz / streamz / dataframe / core.py View on Github external
def _accumulate(self, Agg, **kwargs):
        stream_type = 'updating'

        if isinstance(self.grouper, Streaming):
            stream = self.root.stream.zip(self.grouper.stream)
            grouper_example = self.grouper.example
            agg = Agg(self.index, grouper=None, **kwargs)
        elif isinstance(self.grouper, Window):
            stream = self.root.stream.zip(self.grouper.root.stream)
            grouper_example = self.grouper.root.example
            agg = Agg(self.index, grouper=None, **kwargs)
        else:
            stream = self.root.stream
            grouper_example = self.grouper
            agg = Agg(self.index, grouper=self.grouper, **kwargs)

        # Compute example
        state = agg.initial(self.root.example, grouper=grouper_example)
        if hasattr(grouper_example, 'iloc'):
            grouper_example = grouper_example.iloc[:0]
        elif isinstance(grouper_example, (np.ndarray, pd.Index)):
            grouper_example = grouper_example[:0]
        _, example = agg.on_new(state,
                                self.root.example.iloc[:0],
github python-streamz / streamz / streamz / dataframe / core.py View on Github external
groupby-aggregations.

        Examples
        --------
        >>> df.window(n=10).std()
        >>> df.window(value='2h').count()

        >>> w = df.window(n=100)
        >>> w.groupby(w.name).amount.sum()
        >>> w.groupby(w.x % 10).y.var()

        See Also
        --------
        DataFrame.rolling: mimic's Pandas rolling aggregations
        """
        return Window(self, n=n, value=value)