Can not infer schema for type: <type 'str'>
Question: I have the following Python code that uses Spark:

    
    
    from pyspark.sql import Row
    
    def simulate(a, b, c):
      dict = Row(a=a, b=b, c=c)
      df = sqlContext.createDataFrame(dict)
      return df
    
    df = simulate("a","b",10)
    df.collect()
    

I am creating a `Row` object and I want to save it as a `DataFrame`.

However, I am getting this error:

    
    
    TypeError: Can not infer schema for type: <type 'str'>
    

It occurs on this line:

    
    
    df = sqlContext.createDataFrame(dict)
    

What am I doing wrong?


Answer: It is pointless to create single element data frame. If you want to make it
work despite that use list: `df = sqlContext.createDataFrame([dict])`

