huaxingao commented on issue #23741: [SPARK-22798][PYTHON][ML]Add multiple 
column support to PySpark StringIndexer
URL: https://github.com/apache/spark/pull/23741#issuecomment-461991531
 
 
   @holdenk Do you mean something like this:
   ```
       def _new_java_array(pylist, java_class):
           sc = SparkContext._active_spark_context
           java_array = None
           if len(pylist) > 0 and not isinstance(pylist[0], list): # 1D array
               java_array = sc._gateway.new_array(java_class, len(pylist))
               for i in xrange(len(pylist)):
                   java_array[i] = pylist[i]
           else: # 2D array
               inner_array_length = 0
               for i in xrange(len(pylist)):
                   inner_array_length = max(inner_array_length, len(pylist[i]))
               java_array = sc._gateway.new_array(java_class, len(pylist), 
inner_array_length) 
               for i in xrange(len(pylist)):
                   java_array[i] = JavaWrapper._new_java_array2 (pylist[i], 
java_class)
           return java_array
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to