You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (Jira)" <ji...@apache.org> on 2020/05/03 04:09:00 UTC

[jira] [Commented] (SPARK-31600) Error message from DataFrame creation is misleading.

    [ https://issues.apache.org/jira/browse/SPARK-31600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17098213#comment-17098213 ] 

Hyukjin Kwon commented on SPARK-31600:
--------------------------------------

'b' is bad too because Spark takes nan as a double, and 'aaa' as a string. Both can't find a common type, and it threw an exception.

> Error message from DataFrame creation is misleading.
> ----------------------------------------------------
>
>                 Key: SPARK-31600
>                 URL: https://issues.apache.org/jira/browse/SPARK-31600
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.4.5
>         Environment: DataBricks 6.4, Spark 2.4.5, Scala 2.11
>            Reporter: Olexiy Oryeshko
>            Priority: Major
>
> *Description:*
> DataFrame creation from pandas.DataFrame fails when one of the features contains only NaN values (which is ok).
> However, error message mentions wrong feature as the culprit, which makes it hard to find the root cause.
> *How to reproduce:*
>  
> {code:java}
> import numpy as np
> import pandas as pd
> df2 = pd.DataFrame({'a': np.array([np.nan, np.nan], dtype=np.object_), 'b': [np.nan, 'aaa']})
> display(spark.createDataFrame(df2[['b']]))   # Works fine
> spark.createDataFrame(df2)            # Raises TypeError.
> {code}
> In the code above, column 'a' is bad. However, the `TypeError` raised in the last command mentions feature 'b' as the culprit:
> TypeError: field b: Can not merge type <class 'pyspark.sql.types.DoubleType'> and <class 'pyspark.sql.types.StringType'>
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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