Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4528#discussion_r24481115
  
    --- Diff: python/pyspark/sql/context.py ---
    @@ -336,19 +353,28 @@ def createDataFrame(self, rdd, schema=None, 
samplingRatio=None):
             >>> df3.collect()
             [Row(name=u'Alice', age=1)]
             """
    -        if isinstance(rdd, DataFrame):
    +        if isinstance(data, DataFrame):
                 raise TypeError("rdd is already a DataFrame")
     
    -        if isinstance(schema, StructType):
    -            return self.applySchema(rdd, schema)
    -        else:
    -            if isinstance(schema, (list, tuple)):
    -                first = rdd.first()
    -                if not isinstance(first, (list, tuple)):
    -                    raise ValueError("each row in `rdd` should be list or 
tuple")
    -                row_cls = Row(*schema)
    -                rdd = rdd.map(lambda r: row_cls(*r))
    -            return self.inferSchema(rdd, samplingRatio)
    +        if has_pandas and isinstance(data, pandas.DataFrame):
    --- End diff --
    
    No, user cannot create a pandas.DataFrame object if pandas is not available.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to