我見過很多人建議Dataframe.explode這樣做是一種有用的方法,但是它導致的行數比原始數據幀多,這根本不是我想要的。我只想做非常簡單的Dataframe等效項:rdd.map(lambda row: row + [row.my_str_col.split('-')])它看起來像:col1 | my_str_col-----+----------- 18 | 856-yygrm 201 | 777-psgdg并將其轉換為:col1 | my_str_col | _col3 | _col4-----+------------+-------+------ 18 | 856-yygrm | 856 | yygrm 201 | 777-psgdg | 777 | psgdg我知道pyspark.sql.functions.split(),但是它導致嵌套的數組列,而不是像我想要的兩個頂級列。理想情況下,我也希望這些新列也被命名。
添加回答
舉報
0/150
提交
取消