xinrong-meng opened a new pull request, #38473:
URL: https://github.com/apache/spark/pull/38473

   ### What changes were proposed in this pull request?
   Support DataFrame creation from 2d NumPy array with arbitrary columns.
   
   ### Why are the changes needed?
   Currently, DataFrame creation from 2d ndarray works only with 2 columns. We 
should provide complete support for DataFrame creation with 2d ndarray. 
   
   As part of [SPARK-39405](https://issues.apache.org/jira/browse/SPARK-39405).
   
   ### Does this PR introduce _any_ user-facing change?
   Yes.
   Before
   ```py
   >>> spark.createDataFrame(np.array([[1], [2]])).dtypes
   Traceback (most recent call last):
   ...
       raise ValueError(f"Shape of passed values is {passed}, indices imply 
{implied}")
   ValueError: Shape of passed values is (2, 1), indices imply (2, 2)
   
   
   >>> spark.createDataFrame(np.array([[1, 1, 1], [2, 2, 2]])).dtypes
   Traceback (most recent call last):
   ...
       raise ValueError(f"Shape of passed values is {passed}, indices imply 
{implied}")
   ValueError: Shape of passed values is (2, 3), indices imply (2, 2)
   ```
   
   After
   ```py
   >>> spark.createDataFrame(np.array([[1], [2]])).dtypes
   [('value', 'bigint')]
   
   >>> spark.createDataFrame(np.array([[1, 1, 1], [2, 2, 2]])).dtypes
   [('_1', 'bigint'), ('_2', 'bigint'), ('_3', 'bigint')]
   ```
   
   ### How was this patch tested?
   Unit tests.
   
   


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to