Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
324 views
in Technique[技术] by (71.8m points)

python - 如何使用Pyspark在数据帧中将给定列表添加为ArrayType(StringType)(How can I add a given List as an ArrayType(StringType) in dataframe using Pyspark)

I've a spark dataframe where a fixed array or list is to be added in a new column.

(我有一个火花数据框,其中将固定数组或列表添加到新列中。)

Hours = ['hr01', 'hr02', 'hr23', 'hr24']

This list is to be added as a new column "Hours" in existing dataframe, please help with the pyspark syntax.

(此列表将作为现有数据框中的新列“小时”添加,请使用pyspark语法。)

Dataframe should look as :

(数据框应如下所示:)

id | Date | Hours
1  | 2019-12-01  | ['hr01', 'hr02', 'hr23', 'hr24']
2  | 2019-12-01  | ['hr01', 'hr02', 'hr23', 'hr24']

.

(。)

.

(。)

.

(。)

  ask by learner translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...