Python pandas.core.frame.DataFrame.fillna() Examples

The following are 17 code examples of pandas.core.frame.DataFrame.fillna(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas.core.frame.DataFrame , or try the search function .
Example #1
Source Project: recruit   Author: Frank-qlu   File: groupby.py    License: Apache License 2.0 6 votes vote down vote up
def pad(self, limit=None):
        """
        Forward fill the values.

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.pad
        DataFrame.pad
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('ffill', limit=limit) 
Example #2
Source Project: recruit   Author: Frank-qlu   File: groupby.py    License: Apache License 2.0 6 votes vote down vote up
def backfill(self, limit=None):
        """
        Backward fill the values.

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.backfill
        DataFrame.backfill
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('bfill', limit=limit) 
Example #3
Source Project: vnpy_crypto   Author: birforce   File: groupby.py    License: MIT License 6 votes vote down vote up
def pad(self, limit=None):
        """
        Forward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.pad
        DataFrame.pad
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('ffill', limit=limit) 
Example #4
Source Project: vnpy_crypto   Author: birforce   File: groupby.py    License: MIT License 6 votes vote down vote up
def backfill(self, limit=None):
        """
        Backward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.backfill
        DataFrame.backfill
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('bfill', limit=limit) 
Example #5
Source Project: predictive-maintenance-using-machine-learning   Author: awslabs   File: groupby.py    License: Apache License 2.0 6 votes vote down vote up
def pad(self, limit=None):
        """
        Forward fill the values.

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.pad
        DataFrame.pad
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('ffill', limit=limit) 
Example #6
Source Project: predictive-maintenance-using-machine-learning   Author: awslabs   File: groupby.py    License: Apache License 2.0 6 votes vote down vote up
def backfill(self, limit=None):
        """
        Backward fill the values.

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.backfill
        DataFrame.backfill
        Series.fillna
        DataFrame.fillna
        """
        return self._fill('bfill', limit=limit) 
Example #7
Source Project: Splunking-Crime   Author: nccgroup   File: groupby.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def _transform_fast(self, result, obj):
        """
        Fast transform path for aggregations
        """
        # if there were groups with no observations (Categorical only?)
        # try casting data to original dtype
        cast = (self.size().fillna(0) > 0).any()

        # for each col, reshape to to size of original frame
        # by take operation
        ids, _, ngroup = self.grouper.group_info
        output = []
        for i, _ in enumerate(result.columns):
            res = algorithms.take_1d(result.iloc[:, i].values, ids)
            if cast:
                res = self._try_cast(res, obj.iloc[:, i])
            output.append(res)

        return DataFrame._from_arrays(output, columns=result.columns,
                                      index=obj.index) 
Example #8
Source Project: elasticintel   Author: securityclippy   File: groupby.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _transform_fast(self, result, obj):
        """
        Fast transform path for aggregations
        """
        # if there were groups with no observations (Categorical only?)
        # try casting data to original dtype
        cast = (self.size().fillna(0) > 0).any()

        # for each col, reshape to to size of original frame
        # by take operation
        ids, _, ngroup = self.grouper.group_info
        output = []
        for i, _ in enumerate(result.columns):
            res = algorithms.take_1d(result.iloc[:, i].values, ids)
            if cast:
                res = self._try_cast(res, obj.iloc[:, i])
            output.append(res)

        return DataFrame._from_arrays(output, columns=result.columns,
                                      index=obj.index) 
Example #9
Source Project: recruit   Author: Frank-qlu   File: groupby.py    License: Apache License 2.0 5 votes vote down vote up
def _transform_should_cast(self, func_nm):
        """
        Parameters:
        -----------
        func_nm: str
            The name of the aggregation function being performed

        Returns:
        --------
        bool
            Whether transform should attempt to cast the result of aggregation
        """
        return (self.size().fillna(0) > 0).any() and (
            func_nm not in base.cython_cast_blacklist) 
Example #10
Source Project: vnpy_crypto   Author: birforce   File: groupby.py    License: MIT License 5 votes vote down vote up
def _transform_should_cast(self, func_nm):
        """
        Parameters:
        -----------
        func_nm: str
            The name of the aggregation function being performed

        Returns:
        --------
        bool
            Whether transform should attempt to cast the result of aggregation
        """
        return (self.size().fillna(0) > 0).any() and (func_nm not in
                                                      _cython_cast_blacklist) 
Example #11
Source Project: predictive-maintenance-using-machine-learning   Author: awslabs   File: groupby.py    License: Apache License 2.0 5 votes vote down vote up
def _transform_should_cast(self, func_nm):
        """
        Parameters:
        -----------
        func_nm: str
            The name of the aggregation function being performed

        Returns:
        --------
        bool
            Whether transform should attempt to cast the result of aggregation
        """
        return (self.size().fillna(0) > 0).any() and (
            func_nm not in base.cython_cast_blacklist) 
Example #12
Source Project: Splunking-Crime   Author: nccgroup   File: groupby.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def pad(self, limit=None):
        """
        Forward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.fillna
        DataFrame.fillna
        """
        return self.apply(lambda x: x.ffill(limit=limit)) 
Example #13
Source Project: Splunking-Crime   Author: nccgroup   File: groupby.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def backfill(self, limit=None):
        """
        Backward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.fillna
        DataFrame.fillna
        """
        return self.apply(lambda x: x.bfill(limit=limit)) 
Example #14
Source Project: Splunking-Crime   Author: nccgroup   File: groupby.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def _transform_fast(self, func):
        """
        fast version of transform, only applicable to
        builtin/cythonizable functions
        """
        if isinstance(func, compat.string_types):
            func = getattr(self, func)

        ids, _, ngroup = self.grouper.group_info
        cast = (self.size().fillna(0) > 0).any()
        out = algorithms.take_1d(func().values, ids)
        if cast:
            out = self._try_cast(out, self.obj)
        return Series(out, index=self.obj.index, name=self.obj.name) 
Example #15
Source Project: elasticintel   Author: securityclippy   File: groupby.py    License: GNU General Public License v3.0 5 votes vote down vote up
def pad(self, limit=None):
        """
        Forward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.fillna
        DataFrame.fillna
        """
        return self.apply(lambda x: x.ffill(limit=limit)) 
Example #16
Source Project: elasticintel   Author: securityclippy   File: groupby.py    License: GNU General Public License v3.0 5 votes vote down vote up
def backfill(self, limit=None):
        """
        Backward fill the values

        Parameters
        ----------
        limit : integer, optional
            limit of how many values to fill

        See Also
        --------
        Series.fillna
        DataFrame.fillna
        """
        return self.apply(lambda x: x.bfill(limit=limit)) 
Example #17
Source Project: elasticintel   Author: securityclippy   File: groupby.py    License: GNU General Public License v3.0 5 votes vote down vote up
def _transform_fast(self, func):
        """
        fast version of transform, only applicable to
        builtin/cythonizable functions
        """
        if isinstance(func, compat.string_types):
            func = getattr(self, func)

        ids, _, ngroup = self.grouper.group_info
        cast = (self.size().fillna(0) > 0).any()
        out = algorithms.take_1d(func().values, ids)
        if cast:
            out = self._try_cast(out, self.obj)
        return Series(out, index=self.obj.index, name=self.obj.name)