Jul-14-2022, 06:00 PM
Hey
I have many large data frames that I need to split into several new data frames.
they need to be split in rolling window split. In this case the window is 12. But it can change.
FOr instance I Now have 250 row that I split into data frames like this... as you can see this is a very long end repetitive way to do this.. I believe there must be a smarter way to do this.
Maybe make a for loop or something that can simplify this.
Thanks for advice!
I have many large data frames that I need to split into several new data frames.
they need to be split in rolling window split. In this case the window is 12. But it can change.
FOr instance I Now have 250 row that I split into data frames like this... as you can see this is a very long end repetitive way to do this.. I believe there must be a smarter way to do this.
#df1 = df_all_sales.iloc[0:12].. df2 = df_all_sales.iloc[1:13].. and on and on df1 = pd.DataFrame(df_all_sales, columns=['time', 'sales-transaction']).iloc[0:12] df2 = pd.DataFrame(df_all_sales, columns=['time', 'sales-transaction']).iloc[1:13] df3 = pd.DataFrame(df_all_sales, columns=['time', 'sales-transaction'])iloc[2:14] df4 = pd.DataFrame(df_all_sales, columns=['time', 'sales-transaction']).iloc[3:15]I need help to simplify and reduce the code to something so I can easily access the new Dfs.
Maybe make a for loop or something that can simplify this.
Thanks for advice!