I am working on another aspect of my project but using a csv I downloaded from Mesowest for my experiment. The new code is
df_pirates_all = pd.read_csv(
"https://cdn.touringplans.com/datasets/pirates_of_caribbean_dlr.csv",usecols=['date','datetime','SPOSTMIN'],
parse_dates=['date', 'datetime'],
)
df_pirates_all['ride'] = 'pirates'
df_pirates_all['open'] = ~((df_pirates_all['SPOSTMIN'] == -999))
df_pirates = df_pirates_all.set_index('datetime').sort_index()
df_pirates = df_pirates.loc['2017-01-01 06:00':'2017-02-01 00:00']
c = df_pirates.groupby(level=0).transform("count")
c[c["date"]>1].index.tolist()
df_pirates = df_pirates[~df_pirates.index.isin(c[c["date"]>1].index.tolist())].resample('10Min').fillna("nearest",limit=1)
wxdataadd="C:/Users/stratus/Downloads/DisneyJanuary2017Wx.csv"
wx=pd.read_csv(wxdataadd)
wxdata=wx.resample('10Min')
temp=wxdata['air_temp_set_1']
time=wxdata['Date_Time']
wxtest=pd.concat([df_pirates, temp,time])
wxtest=wxtest.set_index([df_pirates,temp]).unstack()
print (wxtest)
However I am getting a
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'
with respect to the resampling of the weather data as the wxdata has values in columns:
Index(['Date_Time', 'air_temp_set_1', 'relative_humidity_set_1',
'wind_speed_set_1', 'wind_direction_set_1', 'wind_gust_set_1',
'precip_accum_since_local_midnight_set_1'],
dtype='object')
which are every 5 minutes when I want to set it to every 10 or even 15 to line up nicely with the ride data.
Here is the first few lines of wx:
However, I know that the times in the wx does not line up with the one for pirates.