from collections import defaultdict a = np.arange(1, 11 ,1) b = np.arange(1, 20, 2) df = pd.DataFrame({'a': a, 'b': b}) now_df = defaultdict() for i in range(2): now_df[i] = df[df['a']% 2 == i].reset_index()
using reset_index() we can divide data, fit the model and then add again (esp on time axis)
hdfs = [] df = [] for i in range(7): now_df = df[df['ds'].dt.dayofweek == i].reset_index() . . model fitting(params = sm.optimizing(data = data, iter = 1000) . now_hdf = pd.concat([now_df, pd.DataFrame(params['yhat'], columns =[ 'yhat'], axis = 1)
divide the dates based on weekday and divide -> fit -> concat (axis =1)
Comment is the energy for a writer, thanks!