How to use the omegaml.mdataframe.MSeries function in omegaml

To help you get started, we’ve selected a few omegaml 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 omegaml / omegaml / omegaml / mdataframe.py View on Github external
def _get_cursor(self):
        if self.is_unique:
            # this way indexes get applied
            cursor = self.collection.distinct(make_tuple(self.columns)[0])
        else:
            cursor = super(MSeries, self)._get_cursor()
        return cursor
github omegaml / omegaml / omegaml / mdataframe.py View on Github external
* a list or tuple of scalar index values, e.g. .loc[(1,2,3)]
        * a slice of values e.g. .loc[1:5]
        * a list of slices, e.g. .loc[1:5, 2:3]

        :return: the sliced part of the MDataFrame
        """
        filterq, projection = self._get_filter(specs)
        df = self.mdataframe
        if filterq:
            df = self.mdataframe.query(filterq)
            df.from_loc_indexer = True
            df.from_loc_range = self._from_range
        if projection:
            df = df[projection]
        if isinstance(self.mdataframe, MSeries):
            df = df._as_mseries(df.columns[0])
        if getattr(df, 'immediate_loc', False):
            df = df.value
        return df
github omegaml / omegaml / omegaml / mdataframe.py View on Github external
def __getitem__(self, cols_or_slice):
        if isinstance(cols_or_slice, Filter):
            return MSeries(self.collection, columns=self.columns,
                           query=cols_or_slice.query)
        return super(MSeries, self).__getitem__(cols_or_slice)
github omegaml / omegaml / omegaml / mdataframe.py View on Github external
def __getattr__(self, attr):
        if attr in MDataFrame.STATFUNCS:
            return self.statfunc(attr)
        if attr in self.columns:
            kwargs = self._getcopy_kwargs()
            kwargs.update(columns=attr)
            return MSeries(self.collection, **kwargs)
        raise AttributeError(attr)
github omegaml / omegaml / omegaml / mdataframe.py View on Github external
def _as_mseries(self, column):
        kwargs = self._getcopy_kwargs()
        kwargs.update(columns=make_tuple(column))
        return MSeries(self.collection, **kwargs)
github omegaml / omegaml / omegaml / mixins / mdf / apply.py View on Github external
def apply(self, fn, inplace=False, preparefn=None):
        if inplace:
            obj = self
        else:
            kwargs = self._getcopy_kwargs()
            kwargs.update(preparefn=preparefn)
            if isinstance(self, MSeries):
                obj = MSeries(self.collection, **kwargs)
            else:
                obj = MDataFrame(self.collection, **kwargs)
        obj.apply_fn = fn
        return obj
github omegaml / omegaml / omegaml / mixins / mdf / apply.py View on Github external
def apply(self, fn, inplace=False, preparefn=None):
        if inplace:
            obj = self
        else:
            kwargs = self._getcopy_kwargs()
            kwargs.update(preparefn=preparefn)
            if isinstance(self, MSeries):
                obj = MSeries(self.collection, **kwargs)
            else:
                obj = MDataFrame(self.collection, **kwargs)
        obj.apply_fn = fn
        return obj