from timezonefinder import TimezoneFinder
import pandas as pd
tf = TimezoneFinder()
df = pd.DataFrame({'latitude': [-22.540556,-22.950556,-22.967778], 'longitude': [-43.149167,-43.230833,-43.234444], 'timezone': [0,0,0]})
TimeZone = tf.timezone_at(lng=df['longitude'], lat=df['latitude'])
df['timezone'].apply(TimeZone)
print(df)
Hello, new to Python and struggling to get TimeZoneFinder to work for me. I want to apply timezone_at() to the TimeZone column based on geolocations from 2 other columns. Any advice on how to make this work?
Error:
Traceback (most recent call last):
File "C:/Users/mhembree/PycharmProjects/Python/Test Column Add.py", line 17, in <module>
TimeZone = tf.timezone_at(lng=df['longitude'], lat=df['latitude'])
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\timezonefinder\functional.py", line 27, in wrapper
return func(*args, **kwargs)
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\timezonefinder\timezonefinder.py", line 483, in timezone_at
if lng > 180.0 or lng < -180.0 or lat > 90.0 or lat < -90.0:
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\pandas\core\generic.py", line 955, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().