Created
July 19, 2021 02:07
-
-
Save voycey/aee0fee1564594979fdf7d7fc7742e95 to your computer and use it in GitHub Desktop.
Convenience fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapped_readings_df = mapped_readings_df \ | |
.withColumn("week_of_year", F.weekofyear(reading_time)) \ | |
.withColumn("date_str", F.regexp_replace(F.col("period_end").substr(1,10), "-", "")) \ | |
.withColumn("day_of_month", F.dayofmonth(reading_time)) \ | |
.withColumn("month", F.month(reading_time)) \ | |
.withColumn("year", F.year(reading_time)) \ | |
.withColumn("hour", F.hour(reading_time)) \ | |
.withColumn("minute", F.minute(reading_time)) \ | |
.withColumn("reading_date_time", reading_time) \ | |
.withColumn("ingestion_date", F.current_timestamp()) \ | |
.drop("reading_time") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment