Skip to content Skip to sidebar Skip to footer

Timezone Conversion With Pyspark From Timestamp And Country

I'm trying to convert UTC date to date with local timezone (using the country) with PySpark. I have the country as string and the date as timestamp So the input is : date = Timesta

Solution 1:

Use tzinfo instance and not string as timezone.

>>> timezone_name = pytz.country_timezones(country)[0]
>>> timezone_name
'Europe/Paris'
>>> timezone = pytz.timezone(timezone_name)
>>> timezone
<DstTzInfo 'Europe/Paris' LMT+0:09:00 STD>
>>> 

Post a Comment for "Timezone Conversion With Pyspark From Timestamp And Country"