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.
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!
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.
1 2 3 4 5 |
#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 ] |
Maybe make a for loop or something that can simplify this.
Thanks for advice!
Larz60+ write Jul-15-2022, 09:20 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use bbcode tags on future posts.