[
https://issues.apache.org/jira/browse/SPARK-60646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136231#comment-18136231
]
Ramesh Thamizhselvan commented on SPARK-60646:
----------------------------------------------
https://github.com/apache/spark/pull/60013/files
> pandas-on-Spark Series.fillna rejects a Series fill value from the same
> DataFrame
> ---------------------------------------------------------------------------------
>
> Key: SPARK-60646
> URL: https://issues.apache.org/jira/browse/SPARK-60646
> Project: Spark
> Issue Type: Bug
> Components: Pandas API on Spark, PySpark
> Affects Versions: 4.2.0
> Environment: Platform: Ubuntu 24.04 Linux-6.17.0-29-generic x86_64
> Python: 3.11.17
> pyspark 4.2.0
> findspark 2.0.1
> pandas 3.0.6
> numpy 2.4.6
> Reporter: asddfl
> Priority: Critical
>
> Filling a missing floating-point value with the corresponding value from
> another column of the same DataFrame fails in the pandas API on Spark. Pandas
> accepts the aligned Series fill value and returns 1.0.
> {code:python}
> import pandas as pd
> import numpy as np
> from pyspark.sql import SparkSession
> import pyspark.pandas as ps
> t0 = pd.DataFrame({'c0': [np.nan], 'c1': [1.0]})
> print("Pandas:", flush=True)
> result = t0['c0'].fillna(t0['c1'])
> print(result, flush=True)
> spark = (
> SparkSession.builder
> .master("local[2]")
> .config("spark.sql.ansi.enabled", "false")
> .config("spark.sql.shuffle.partitions", "2")
> .getOrCreate()
> )
> t0 = ps.DataFrame({'c0': [np.nan], 'c1': [1.0]})
> print("PySpark Pandas:", flush=True)
> result = t0['c0'].fillna(t0['c1'])
> print(result, flush=True)
> spark.stop()
> {code}
> {code:bash}
> Pandas:
> 0 1.0
> Name: c0, dtype: float64
> PySpark Pandas:
> Traceback (most recent call last):
> File "/test.py", line 25, in <module>
> result = t0['c0'].fillna(t0['c1'])
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File
> "/opt/conda/envs/lib/python3.11/site-packages/pyspark/pandas/series.py", line
> 2217, in fillna
> return self._fillna_with_method(
> ^^^^^^^^^^^^^^^^^^^^^^^^^
> File
> "/opt/conda/envs/lib/python3.11/site-packages/pyspark/pandas/series.py", line
> 2233, in _fillna_with_method
> psser = self._fillna(value=value, method=method, axis=axis, limit=limit)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File
> "/opt/conda/envs/lib/python3.11/site-packages/pyspark/pandas/series.py", line
> 2277, in _fillna
> raise TypeError("Unsupported type %s" % type(value).__name__)
> TypeError: Unsupported type Series
> {code}
> *Expected behavior*
> Fill c0's missing value from c1 and return a float Series named c0 containing
> 1.0, matching Pandas.
> *Actual behavior*
> t0['c0'].fillna(t0['c1']) raises TypeError: Unsupported type Series.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]