How to split Vector into columns - using PySpark

后端 未结 5 1337
夕颜
夕颜 2020-11-22 16:23

Context: I have a DataFrame with 2 columns: word and vector. Where the column type of \"vector\" is VectorUDT.

An Example:

5条回答
  •  粉色の甜心
    2020-11-22 17:20

    For anyone trying to split the rawPrediction or probability columns generated after training a PySpark ML model into Pandas columns, you can split like this:

    your_pandas_df['probability'].apply(lambda x: pd.Series(x.toArray()))
    

提交回复
热议问题