0
from pyspark.sql import Row, functions as F
row = Row("UK_1","UK_2","Date","Cat",'Combined')
agg = ''
agg = 'Cat'
tdf = (sc.parallelize
([
row(1,1,'12/10/2016',"A",'Water^World'),
row(1,2,None,'A','Sea^Born'),
row(2,1,'14/10/2016','B','Germ^Any'),
row(3,3,'!~2016/2/276','B','Fin^Land'),
row(None,1,'26/09/2016','A','South^Korea'),
row(1,1,'12/10/2016',"A",'North^America'),
row(1,2,None,'A','South^America'),
row(2,1,'14/10/2016','B','New^Zealand'),
row(None,None,'!~2016/2/276','B','South^Africa'),
row(None,1,'26/09/2016','A','Saudi^Arabia')
]).toDF())
cols = F.split(tdf['Combined'], '^')
tdf = tdf.withColumn('column1', cols.getItem(0))
tdf = tdf.withColumn('column2', cols.getItem(1))
tdf.show(truncate = False )
上記は私のサンプルコードです。Pysparkスプリットカラム
何らかの理由で、^文字で列を分割していません。
アドバイスはありますか?