티스토리 뷰

728x90
df = df.withColumnRenamed("colName", "newColName")\
       .withColumnRenamed("colName2", "newColName2")

https://stackoverflow.com/questions/34077353/how-to-change-dataframe-column-names-in-pyspark

 

How to change dataframe column names in pyspark?

I come from pandas background and am used to reading data from CSV files into a dataframe and then simply changing the column names to something useful using the simple command: df.columns =

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[Java][Spark] add column & default  (0) 2021.09.11
[Java][Spark] pyspark.sql.Row.asDict  (0) 2021.09.11
[Java][Spark] new Row(**dict)  (0) 2021.09.11
[Java] lombok @Data  (0) 2021.09.06
[Mac] Terminal Hostname 변경  (0) 2021.09.05
댓글
댓글쓰기 폼