zhengruifeng commented on code in PR #39360:
URL: https://github.com/apache/spark/pull/39360#discussion_r1060448103


##########
python/pyspark/sql/connect/session.py:
##########
@@ -201,25 +202,24 @@ def createDataFrame(
 
         # Create the Pandas DataFrame
         if isinstance(data, pd.DataFrame):
-            pdf = data
+            table = pa.Table.from_pandas(data)
 
         elif isinstance(data, np.ndarray):
-            # `data` of numpy.ndarray type will be converted to a pandas 
DataFrame,
             if data.ndim not in [1, 2]:
                 raise ValueError("NumPy array input should be of 1 or 2 
dimensions.")
 
-            pdf = pd.DataFrame(data)
-
             if _cols is None:
                 if data.ndim == 1 or data.shape[1] == 1:
                     _cols = ["value"]
                 else:
                     _cols = ["_%s" % i for i in range(1, data.shape[1] + 1)]
 
+            table = pa.Table.from_pylist([dict(zip(_cols, list(item))) for 
item in data])

Review Comment:
   good point, let me have a try



##########
python/pyspark/sql/connect/session.py:
##########
@@ -231,13 +231,21 @@ def createDataFrame(
                         _schema.fields[i].name = name
                         _schema.names[i] = name
 
-            pdf = pd.DataFrame(_data)
-
             if _cols is None:
-                _cols = ["_%s" % i for i in range(1, pdf.shape[1] + 1)]
+                if _schema is None:
+                    _cols = ["_%s" % i for i in range(1, len(_data[0]) + 1)]
+                else:
+                    _cols = _schema.names
+
+            if isinstance(_data[0], Row):
+                table = pa.Table.from_pylist([row.asDict() for row in _data])

Review Comment:
   will update



-- 
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]

Reply via email to