I'm following along with the blog below as a python/R novice and having trouble adding a loop statement to the code below. Currently i'm able to get the code run in full, but only outputs the seasonal flag for 1 customer. I would like it to loop and run for all of my customers.
datamovesme.com/2018/07/01/seasonality-python-code
##Here comes the R code piece     
     try:
          seasonal = r(''' 
          fit<-tbats(customerTS, seasonal.periods = 12, use.parallel = TRUE)
          fit$seasonal
          ''')
      except: seasonal = 1
      seasonal_output = seasonal_output.append({'customer_id':customerid, 'seasonal': seasonal}, ignore_index=True)
      print(f' {customerid} | {seasonal} ')
print(seasonal_output)
seasonal_output.to_csv(outfile)
I've tried many combinations of code to get it to loop, too many to list here. The blog shows the existing data frames, and time-series objects that are available to us. I am not sure which one to use and how to pass it to the R code.
Thanks !
 
    