-
[Spark tip] struct type을 csv로 저장시 에러programming 2019. 4. 8. 16:01
from pyspark.sql.functions import udf from pyspark.sql.types import StringType def array_to_string(my_list): return '[' + ','.join([str(elem) for elem in my_list]) + ']' array_to_string_udf = udf(array_to_string,StringType()) df = df.withColumn('window-stringified',array_to_string_udf(df["window"]))
UDF로 String 포맷으로 List의 모양을 리턴해주는 함수를 정의한다.
그래서 struct type을 string으로 변형해서 저장반응형'programming' 카테고리의 다른 글
how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware (0) 2021.04.11 Schema evolution (0) 2020.06.29 Gevent / Celery 에 대하여 (0) 2019.03.13 Timsort python sorted 알고리즘 (0) 2019.03.13 MSSql Server Password Maximum error (0) 2019.03.13 댓글