Guest User

Untitled

a guest
Mar 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. from pyspark.sql.types import *
  2. from pyspark.sql import functions as F
  3. res = gdf.unionAll(
  4. gdf.select([
  5. F.lit('ALL').alias('SUMMARY_ID'),
  6. F.sum(gdf.upass).alias('upass'),
  7. F.sum(gdf.uin).alias('uin'),
  8. ]))
  9.  
  10.  
  11. def ConvertColumnType(df, col, newType):
  12. df = df.withColumn(col, df[col].cast(newType))
  13. return df
  14.  
  15. gdf = ConvertColumnType(gdf, "upass", IntegerType())
Add Comment
Please, Sign In to add comment