第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將Vector拆分為列 - 使用PySpark

如何將Vector拆分為列 - 使用PySpark

瀟湘沐 2019-07-25 09:53:04
如何將Vector拆分為列 - 使用PySpark上下文:我有DataFrame2列:單詞和向量。其中“vector”的列類型是VectorUDT。一個例子:word    |  vectorassert  | [435,323,324,212...]我希望得到這個:word   |  v1 | v2  | v3 | v4 | v5 | v6 ......assert | 435 | 5435| 698| 356|....題:如何使用PySpark為每個維度拆分包含多列向量的列?提前致謝
查看完整描述

2 回答

?
鴻蒙傳說

TA貢獻1865條經(jīng)驗 獲得超7個贊

def splitVecotr(df, new_features=['f1','f2']):schema = df.schema
cols = df.columnsfor col in new_features: # new_features should be the same length as vector column length
    schema = schema.add(col,DoubleType(),True)return spark.createDataFrame(df.rdd.map(lambda row: [row[i] for i in cols]+row.features.tolist()), schema)

該函數(shù)將特征向量列轉換為單獨的列


查看完整回答
反對 回復 2019-07-25
  • 2 回答
  • 0 關注
  • 2208 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號