You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Len Frodgers (JIRA)" <ji...@apache.org> on 2017/02/24 20:42:44 UTC

[jira] [Created] (SPARK-19732) DataFrame.fillna() does not work for bools in PySpark

Len Frodgers created SPARK-19732:
------------------------------------

             Summary: DataFrame.fillna() does not work for bools in PySpark
                 Key: SPARK-19732
                 URL: https://issues.apache.org/jira/browse/SPARK-19732
             Project: Spark
          Issue Type: Bug
          Components: PySpark
    Affects Versions: 2.1.0
            Reporter: Len Frodgers


In PySpark, the fillna function of DataFrame inadvertently casts bools to ints, so fillna cannot be used to fill True/False.

e.g. `spark.createDataFrame([Row(a=True),Row(a=None)]).fillna(True).collect()` 
yields
`[Row(a=True), Row(a=None)]`
It should be a=True for the second Row

The cause is this bit of code: 
if isinstance(value, (int, long)):
            value = float(value)

There needs to be a separate check for isinstance(bool), since in python, bools are ints too



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org