[
https://issues.apache.org/jira/browse/SPARK-18178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15799122#comment-15799122
]
Bryan Cutler commented on SPARK-18178:
--------------------------------------
The error I get is
{noformat} TypeError: Can not merge type <class 'pyspark.sql.types.StringType'>
and <class 'pyspark.sql.types.DoubleType'> {noformat}
which is because PySpark doesn't do a good job inferring the schema from
Pandas, already reported at SPARK-17804
You could specify the schema yourself, like this
{code}
test_df = pd.read_csv(StringIO(',Scan Options\n15,SAT2\n16,\n'))
schema = StructType([StructField("data", IntegerType(), True),
StructField("Scan Options", StringType(), True)])
sqlContext.createDataFrame(test_df, schema=schema).registerTempTable('Test')
{code}
> Importing Pandas Tables with Missing Values
> -------------------------------------------
>
> Key: SPARK-18178
> URL: https://issues.apache.org/jira/browse/SPARK-18178
> Project: Spark
> Issue Type: Bug
> Components: PySpark
> Affects Versions: 2.0.0
> Reporter: Kevin Mader
>
> If you import a table with missing values (like below) and create a dataframe
> from it, everything works fine until the command is actually execute
> (.first(), or .toPandas(), etc). The problem came up with a much larger table
> with values that were not NAN, just empty.
> ```
> import pandas as pd
> from io import StringIO
> test_df = pd.read_csv(StringIO(',Scan Options\n15,SAT2\n16,\n'))
> sqlContext.createDataFrame(test_df).registerTempTable('Test')
> o_qry = sqlContext.sql("SELECT * FROM Test LIMIT 1")
> o_qry.first()
> ```
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]