Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5274#discussion_r27444527
  
    --- Diff: python/pyspark/sql/dataframe.py ---
    @@ -697,6 +697,83 @@ def subtract(self, other):
             """
             return DataFrame(getattr(self._jdf, "except")(other._jdf), 
self.sql_ctx)
     
    +    def dropna(self, how='any', thresh=None, subset=None):
    +        """Returns a new :class:`DataFrame` omitting rows with null values.
    +
    +        :param how: 'any' or 'all'.
    +            If 'any', drop a row if it contains any nulls.
    +            If 'all', drop a row only if all its values are null.
    +        :param thresh: int, default None
    +            If specified, drop rows that have less than `thresh` non-null 
values.
    +            This overwrites the `how` parameter.
    +        :param subset: optional list of column names to consider.
    +
    +        >>> df4.dropna().show()
    +        age height name
    +        10  80     Alice
    +        """
    +        if subset is None:
    +            subset = self.columns
    +        elif isinstance(subset, basestring):
    +            subset = [subset]
    +        elif not isinstance(subset, (list, tuple)):
    +            raise ValueError("subset should be a list or tuple of column 
names")
    +
    +        if thresh is None:
    +            thresh = len(subset) if how == 'any' else 1
    +
    +        cols = ListConverter().convert(subset, 
self.sql_ctx._sc._gateway._gateway_client)
    +        cols = self.sql_ctx._sc._jvm.PythonUtils.toSeq(cols)
    +        return DataFrame(self._jdf.na().drop(thresh, cols), self.sql_ctx)
    +
    +    def fillna(self, value, subset=None):
    +        """Replace null values.
    +
    +        :param value: int, long, float, string, or dict.
    +            Value to replace null values with.
    +            If the value is a dict, then `subset` is ignored and `value` 
must be a mapping
    +            from column name (string) to replacement value. The 
replacement value must be
    +            an int, long, float, or string.
    +        :param subset: optional list of column names to consider.
    +            Columns specified in subset that do not have matching data 
type are ignored.
    +            For example, if `value` is a string, and subset contains a 
non-string column,
    +            then the non-string column is simply ignored.
    +
    +        >>> df4.fillna(50).show()
    +        age height name
    +        10  80     Alice
    +        5   50     Bob
    +        50  50     Tom
    +        50  50     null
    +
    +        >>> df4.fillna({'age': 50, 'name': 'unknown'}).show()
    +        age height name
    +        10  80     Alice
    +        5   null   Bob
    +        50  null   Tom
    +        50  null   unknown
    +        """
    +        if not isinstance(value, (float, int, long, basestring, dict)):
    +            raise ValueError("value should be a float, int, long, string, 
or dict")
    +
    +        if isinstance(value, (int, long)):
    +            value = float(value)
    --- End diff --
    
    Why we use `float` instead of `int` here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to