You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was so free to actually get the correct error code. It is a 400 bad request code.
It seems it only happens when I use a loop through my pandas dataframe instances because when I run my code for a single instance I am getting the correct values as well as when I am using a direct URL request in my browser.
Here is my function which is called later (with df being the dataframe)
def engineer_features(df):
from datetime import datetime as dt
from darksky import forecast
print("Add weather data...")
# Add Windspeed
df['ISSTORM'] = 0
# Add Temperature
df['ISHOT'] = 0
df['ISCOLD'] = 0
# Add Precipitation probability
# (because the weather station is not at the coordinate of the taxi
# only a probability is added, but in regard to the center of Porto
# (because else the API calls would have been costly))
df['PRECIPPROB'] = 0
# sort data frame
data_times = df.sort_values(by='TIMESTAMP')
# initialize variable for previous day's date day (day before the first day)
prevDay = data_times.at[0,'TIMESTAMP'].date().day - 1
#initialize hour counter
hourCount = 0
# add personal DarkSky API key and asssign with location data
key = 'MYKEY'
PORTO = key, 41.1579, -8.6291
# loop through the sorted dataframe and add weather related data to the main dataframe
for index, row in data_times.iterrows():
# if the new row is a new day make a new API call for weather data of that new day
if row["TIMESTAMP"].day != prevDay:
# get Weather data
t = row["TIMESTAMP"].date().isoformat()
porto = forecast(*PORTO, time=t)
porto.refresh(units='si')
###...more code
The text was updated successfully, but these errors were encountered:
I am getting a
I was so free to actually get the correct error code. It is a 400 bad request code.
It seems it only happens when I use a loop through my pandas dataframe instances because when I run my code for a single instance I am getting the correct values as well as when I am using a direct URL request in my browser.
Here is my function which is called later (with
df
being the dataframe)The text was updated successfully, but these errors were encountered: