I have a numpy matrix:
arr = np.array([[2,3], [2,8], [2,3],[4,5]])
I need to create a PySpark Dataframe from arr
. I can not manually input the values because the length/values of arr
will be changing dynamically so I need to convert arr
into a dataframe.
I tried the following code to no success.
df= sqlContext.createDataFrame(arr,["A", "B"])
However, I get the following error.
TypeError: Can not infer schema for type: <type 'numpy.ndarray'>