Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pyspark: Convert all dates/times from GMT to Bejing Time. This Requires moving dates, times and timestamps by 8 hours ahead. Code so far: But the
Pyspark: Convert all dates/times from GMT to Bejing Time. This Requires moving dates, times and timestamps by 8 hours ahead.
Code so far: But the issue is the code will only change Time I need the Date to also change accordingly.
import pyspark.sql.functions as F
df = df_pyspark.withColumn('BejingTime', df_pyspark.Time + F.expr('INTERVAL 8 HOURS')) df.show()
"UserID | Latitude | Longitude | AllZero | Altitude | Timestamp | Date | Time" |
"118 | 46.77681667 | 121.7455333 | 0 | 4658.792651 | 39221.99999 | 19/05/2007 | 23:59:59" |
"115 | 39.9861766 | 116.3662633 | 0 | 173.9 | 39572.99999 | 04/05/2008 | 23:59:59" |
"115 | 40.0209133 | 116.4166183 | 0 | 157.5 | 39573.99999 | 05/05/2008 | 23:59:59" |
"115 | 40.0177816 | 116.3743649 | 0 | 131.2 | 39575.99999 | 07/05/2008 | 23:59:59" |
"115 | 39.9756316 | 116.3317099 | 0 | 196.9 | 39616.99999 | 17/06/2008 | 23:59:59" |
"112 | 39.97176 | 116.4605366 | 0 | 124.7 | 39618.99999 | 19/06/2008 | 23:59:59" |
"125 | 40.006229 | 116.324338 | 0 | 265 | 39618.99999 | 19/06/2008 | 23:59:59" |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started