Replaces NaN values with the method provided.

        Returns:
            A new QueryCompiler with null values filled.
518928
def fillna(self, **kwargs):
        
        axis = kwargs.get("axis", 0)
        value = kwargs.get("value")
        if isinstance(value, dict):
            value = kwargs.pop("value")

            if axis == 0:
                index = self.columns
            else:
                index = self.index
            value = {
                idx: value[key] for key in value for idx in index.get_indexer_for([key])
            }

            def fillna_dict_builder(df, func_dict={}):
                # We do this to ensure that no matter the state of the columns we get
                # the correct ones.
                func_dict = {df.columns[idx]: func_dict[idx] for idx in func_dict}
                return df.fillna(value=func_dict, **kwargs)

            new_data = self.data.apply_func_to_select_indices(
                axis, fillna_dict_builder, value, keep_remaining=True
            )
            return self.__constructor__(new_data, self.index, self.columns)
        else:
            func = self._prepare_method(pandas.DataFrame.fillna, **kwargs)
            new_data = self._map_across_full_axis(axis, func)
            return self.__constructor__(new_data, self.index, self.columns)
904278
def _default_to_pandas(self, op, *args, **kwargs):
        """"""
        empty_self_str = "" if not self.empty else " for empty DataFrame"
        ErrorMessage.default_to_pandas(
            "`{}.{}`{}".format(
                self.__name__,
                op if isinstance(op, str) else op.__name__,
                empty_self_str,
            )
        )
        if callable(op):
            result = op(self._to_pandas(), *args, **kwargs)
        elif isinstance(op, str):
            # The inner `getattr` is ensuring that we are treating this object (whether
            # it is a DataFrame, Series, etc.) as a pandas object. The outer `getattr`
            # will get the operation (`op`) from the pandas version of the class and run
            # it on the object after we have converted it to pandas.
            result = getattr(getattr(pandas, self.__name__), op)(
                self._to_pandas(), *args, **kwargs
            )
        # SparseDataFrames cannot be serialize by arrow and cause problems for Modin.
        # For now we will use pandas.
        if isinstance(result, type(self)) and not isinstance(
            result, (pandas.SparseDataFrame, pandas.SparseSeries)
        ):
            return self._create_or_update_from_compiler(
                result, inplace=kwargs.get("inplace", False)
            )
        elif isinstance(result, pandas.DataFrame):
            from .dataframe import DataFrame

            return DataFrame(result)
        elif isinstance(result, pandas.Series):
            from .series import Series

            return Series(result)
        else:
            try:
                if (
                    isinstance(result, (list, tuple))
                    and len(result) == 2
                    and isinstance(result[0], pandas.DataFrame)
                ):
                    # Some operations split the DataFrame into two (e.g. align). We need to wrap
                    # both of the returned results
                    if isinstance(result[1], pandas.DataFrame):
                        second = self.__constructor__(result[1])
                    else:
                        second = result[1]
                    return self.__constructor__(result[0]), second
                else:
                    return result
            except TypeError:
                return result
408763
def _get_result_constructor(self):
        
        if not self._values_list:  # we want models
            return self.model._construct_instance
        elif self._flat_values_list:  # the user has requested flattened list (1 value per row)
            key = self._only_fields[0]
            return lambda row: row[key]
        else:
            return lambda row: [row[f] for f in self._only_fields]
249602
def _maybe_fill(arr, fill_value=np.nan):
    
    if _isna_compat(arr, fill_value):
        arr.fill(fill_value)
    return arr
703302
def _fix_numeric_types(c):
    
    try:
        for var, data in c.items():
            for k, v in data.items():
                if k in ["hasMeanValue", "hasMaxValue", "hasMinValue", "hasMedianValue"]:
                    if math.isnan(v):
                        c[var][k] = "nan"
                    elif not isinstance(v, (int, float)):
                        try:
                            c[var][k] = float(v)
                        except Exception as e:
                            logger_inferred_data.info("fix_numeric_types: converting float: {}".format(e))
                elif k == "hasResolution":
                    for b, g in v.items():
                        if b in ["hasMeanValue", "hasMaxValue", "hasMinValue", "hasMedianValue"]:
                            if math.isnan(g):
                                c[var][k][b] = "nan"
                            elif not isinstance(g, (int, float)):
                                try:
                                    f = float(g)
                                    c[var][k][b] = f
                                except Exception as e:
                                    logger_inferred_data.info("fix_numeric_types: converting float: {}".format(e))
    except Exception as e:
        logger_inferred_data.error("fix_numeric_types: {}".format(e))
    return c
291861
def _add_series_only_operations(cls):
        

        axis_descr, name, name2 = _doc_parms(cls)

        def nanptp(values, axis=0, skipna=True):
            nmax = nanops.nanmax(values, axis, skipna)
            nmin = nanops.nanmin(values, axis, skipna)
            warnings.warn("Method .ptp is deprecated and will be removed "
                          "in a future version. Use numpy.ptp instead.",
                          FutureWarning, stacklevel=4)
            return nmax - nmin

        cls.ptp = _make_stat_function(
            cls, 'ptp', name, name2, axis_descr,
            """Return the difference between the maximum value and the
            minimum value in the object. This is the equivalent of the
            ``numpy.ndarray`` method ``ptp``.\n\n.. deprecated:: 0.24.0
                Use numpy.ptp instead""",
            nanptp)
481167
def _get_result_constructor(self):
        
        if not self._values_list: # we want models
            return lambda rows: self.model._construct_instance(rows)
        elif self._flat_values_list: # the user has requested flattened list (1 value per row)
            return lambda row: row.popitem()[1]
        else:
            return lambda row: self._get_row_value_list(self._only_fields, row)
553180
def insert(self, loc, column, value):
        
        if is_list_like(value):
            # TODO make work with another querycompiler object as `value`.
            # This will require aligning the indices with a `reindex` and ensuring that
            # the data is partitioned identically.
            if isinstance(value, pandas.Series):
                value = value.reindex(self.index)
            value = list(value)

        def insert(df, internal_indices=[]):
            internal_idx = int(internal_indices[0])
            old_index = df.index
            df.index = pandas.RangeIndex(len(df.index))
            df.insert(internal_idx, internal_idx, value, allow_duplicates=True)
            df.columns = pandas.RangeIndex(len(df.columns))
            df.index = old_index
            return df

        new_data = self.data.apply_func_to_select_indices_along_full_axis(
            0, insert, loc, keep_remaining=True
        )
        new_columns = self.columns.insert(loc, column)
        return self.__constructor__(new_data, self.index, new_columns)
1004602
def get_fill_value(dataset):
    """"""
    if np.issubdtype(dataset.dtype, np.integer):
        return dataset.attrs.get('_FillValue', np.nan)
    return np.nan
1066294
def _get_interpolator_nd(method, **kwargs):
    '''
    '''
    valid_methods = ['linear', 'nearest']

    try:
        from scipy import interpolate
    except ImportError:
        raise ImportError(
            'Interpolation with method `%s` requires scipy' % method)

    if method in valid_methods:
        kwargs.update(method=method)
        interp_class = interpolate.interpn
    else:
        raise ValueError('%s is not a valid interpolator for interpolating '
                         'over multiple dimensions.' % method)

    return interp_class, kwargs
704071
def replace(self, parameters=_void, return_annotation=_void):
        

        if parameters is _void:
            parameters = self.parameters.values()

        if return_annotation is _void:
            return_annotation = self._return_annotation

        return type(self)(parameters, return_annotation=return_annotation)
221613
def _hcsi_null_range(*args, **kwargs):
    
    return [
        HCSINullField('Reserved{:02d}'.format(x))
        for x in range(*args, **kwargs)
    ]
593782
def get_nan_locs(self, **kwargs):
        
        if np.issubdtype(self.X.dtype, np.string_) or np.issubdtype(self.X.dtype, np.unicode_):
            mask = np.where( self.X == '' )
            nan_matrix = np.zeros(self.X.shape)
            nan_matrix[mask] = np.nan

        else:
            nan_matrix = self.X.astype(float)

        if self.y is None:
            return np.argwhere(np.isnan(nan_matrix))
        else:
            nan_locs = []
            for target_value in np.unique(self.y):
                indices = np.argwhere(self.y == target_value)
                target_matrix = nan_matrix[indices.flatten()]
                nan_target_locs = np.argwhere(np.isnan(target_matrix))
                nan_locs.append((target_value, nan_target_locs))

            return nan_locs
435557
def fillNullValues(col, rows):
    ''
    lastval = None
    nullfunc = isNullFunc()
    n = 0
    rowsToFill = list(rows)
    for r in Progress(col.sheet.rows, 'filling'):  # loop over all rows
        try:
            val = col.getValue(r)
        except Exception as e:
            val = e

        if nullfunc(val) and r in rowsToFill:
            if lastval:
                col.setValue(r, lastval)
                n += 1
        else:
            lastval = val

    col.recalc()
    status("filled %d values" % n)
275988
def _create_non_null_wrapper(name, t):
    ''
    def __new__(cls, json_data, selection_list=None):
        if json_data is None:
            raise ValueError(name + ' received null value')
        return t(json_data, selection_list)

    def __to_graphql_input__(value, indent=0, indent_string='  '):
        return t.__to_graphql_input__(value, indent, indent_string)

    return type(name, (t,), {
        '__new__': __new__,
        '_%s__auto_register' % name: False,
        '__to_graphql_input__': __to_graphql_input__,
    })
175833
def fill_null_values(self):
        
        if not self.Model:
            log.info("%s has no model defined" % self.__class__.__name__)
            return

        empty_values = self.Model.get_null_values()
        for field, value in empty_values.items():
            if field not in self._json_params:
                self._json_params[field] = value
68647
def nullify(v):
    

    if isinstance(v, six.string_types):
        v = v.strip()

    if v is None or v == '':
        return None
    else:
        return v