How to use the retentioneering.core.preprocessing.split_sessions function in retentioneering

To help you get started, we’ve selected a few retentioneering 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 retentioneering / retentioneering-tools / retentioneering / core / utils.py View on Github external
by_event: str, optional
             If ``None``, sessions are automatically defined with time diffrence between events, else splits sessions by specific event in ``event_col``. For instance, if you have a technical event in your dataset defining a new user session, you may specify it in ``by_event`` to split sessions based on this event. Default: ``None``
        minimal_thresh: int, optional
            Minimal threshold in seconds between two sessions. Default: ``30``

        Returns
        -------
        Creates ``session`` column in dataset.

        Return type
        -------
        pd.DataFrame
        """
        self._init_cols(locals())
        if by_event is None:
            preprocessing.split_sessions(self._obj, minimal_thresh=minimal_thresh)
        else:
            self._obj['session'] = self._obj[self._event_col()] == by_event
            self._obj['session'] = self._obj.groupby(self._index_col()).session.cumsum()