zhengruifeng commented on code in PR #38803:
URL: https://github.com/apache/spark/pull/38803#discussion_r1033063659
##########
python/pyspark/sql/connect/session.py:
##########
@@ -205,6 +207,34 @@ def __init__(self, connectionString: str, userId:
Optional[str] = None):
# Create the reader
self.read = DataFrameReader(self)
+ def createDataFrame(self, data: "pd.DataFrame") -> "DataFrame":
+ """
+ Creates a :class:`DataFrame` from a :class:`pandas.DataFrame`.
+
+ .. versionadded:: 3.4.0
+
+
+ Parameters
+ ----------
+ data : :class:`pandas.DataFrame`
+
+ Returns
+ -------
+ :class:`DataFrame`
+
+ Examples
+ --------
+ >>> import pandas
+ >>> pdf = pandas.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]})
+ >>> self.connect.createDataFrame(pdf).collect()
+ [Row(a=1, b='a'), Row(a=2, b='b'), Row(a=3, b='c')]
+
+ """
+ assert data is not None
+ if len(data) == 0:
+ raise ValueError("Input data cannot be empty")
Review Comment:
IIRC, `createDataFrame` in pyspark doesnot support empty pandas dataframe. I
think it would be fine to throw an error here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]