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


##########
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:
   I think we should use `pa.Table.from_arrays` (and covert the input NumPy 
array by `pa.array(data)`). This is actually pretty critical for performance 
because of memoryview implementation 



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