I have this dataset where I have 50076 observations. Where I have 78 different location codes. I am interested in dividing the data into 78 smaller sets based on the level2code, where I will have 642 new entries for every location code I have in the dataset. I want to do this in for loop and then apply train/test on all the data frames Please, anyone, help me to build the logic here or any code sample.
Data is on daily basis. Dataset range: 2021/04 to 2021/10
Sample of the dataset:
date product level2code pred
04/04/2021 garri NG020001 364.9078403
04/04/2021 garri NG020002 405.0176459
04/04/2021 garri NG020003 355.6559092
04/04/2021 garri NG021001 367.8924441
04/04/2021 garri NG021002 339.8849381
04/04/2021 garri NG021003 404.0443164
04/04/2021 garri NG021004 322.449294
04/04/2021 garri NG020004 373.4328204
04/04/2021 garri NG020005 340.3411411
04/04/2021 garri NG021005 371.7665644
04/04/2021 garri NG020006 385.0198551
04/04/2021 garri NG021006 373.823132
04/04/2021 garri NG020007 484.2053413
04/04/2021 garri NG020008 359.3935806
04/04/2021 garri NG021007 353.6156045
04/04/2021 garri NG021008 378.1871792
04/04/2021 garri NG021009 387.2898271
04/04/2021 garri NG021010 317.7764771
04/04/2021 garri NG020009 400.6413871
04/04/2021 garri NG020010 350.8766674
04/04/2021 garri NG020011 229.2244298
04/04/2021 garri NG021011 339.4917639
04/04/2021 garri NG021012 330.6837624
04/04/2021 garri NG020012 407.9777664
04/04/2021 garri NG021013 402.9517871
04/04/2021 garri NG021014 348.0097185
04/04/2021 garri NG020013 364.2464053
04/04/2021 garri NG020014 418.7499592
04/04/2021 garri NG020015 360.938317
04/04/2021 garri NG020016 350.4084329
04/04/2021 garri NG020017 375.72284
04/04/2021 garri NG020018 427.3577787
04/04/2021 garri NG020019 366.9704695
04/04/2021 garri NG021015 339.4269696
04/04/2021 garri NG021016 336.4246695
04/04/2021 garri NG020020 388.3874728
04/04/2021 garri NG021017 394.1519307
04/04/2021 garri NG021018 344.7673375
04/04/2021 garri NG021019 341.0985795
04/04/2021 garri NG021020 352.5840756
04/04/2021 garri NG020021 451.686015
04/04/2021 garri NG020022 372.5480642
04/04/2021 garri NG021021 416.9292449
04/04/2021 garri NG020023 413.1212566
04/04/2021 garri NG020024 285.1784935
04/04/2021 garri NG020025 382.6852787
04/04/2021 garri NG020026 342.855628
04/04/2021 garri NG020027 391.6584643
04/04/2021 garri NG021022 393.6701502
04/04/2021 garri NG021023 390.734382
04/04/2021 garri NG020028 330.6206827
04/04/2021 garri NG021024 379.6972674
04/04/2021 garri NG020029 436.934722
04/04/2021 garri NG021025 359.5709573
04/04/2021 garri NG021026 370.7826172
04/04/2021 garri NG021027 389.0357557
04/04/2021 garri NG021028 364.390563
04/04/2021 garri NG020030 394.8899018
04/04/2021 garri NG021029 354.6026948
04/04/2021 garri NG020031 450.8422956
04/04/2021 garri NG020032 395.4807888
04/04/2021 garri NG021030 368.8909271
04/04/2021 garri NG020033 345.542072
04/04/2021 garri NG020034 368.6961538
04/04/2021 garri NG021031 362.4843737
04/04/2021 garri NG021032 351.5487247
04/04/2021 garri NG021033 333.1110479
04/04/2021 garri NG020035 352.4340719
04/04/2021 garri NG020036 376.2629423
04/04/2021 garri NG020037 383.4869235
04/04/2021 garri NG020038 428.4209467
04/04/2021 garri NG020039 348.4337737
04/04/2021 garri NG020040 379.4867464
04/04/2021 garri NG020041 311.566191
04/04/2021 garri NG020042 386.7846334
04/04/2021 garri NG020043 398.7175982
04/04/2021 garri NG020044 385.876016
04/04/2021 garri NG021034 340.200124
04/04/2021 local_rice NG020001 364.9078403
04/04/2021 local_rice NG020002 405.0176459
04/04/2021 local_rice NG020003 355.6559092
04/04/2021 local_rice NG021001 367.8924441
04/04/2021 local_rice NG021002 339.8849381
04/04/2021 local_rice NG021003 404.0443164
04/04/2021 local_rice NG021004 322.449294
04/04/2021 local_rice NG020004 373.4328204
04/04/2021 local_rice NG020005 340.3411411
04/04/2021 local_rice NG021005 371.7665644
04/04/2021 local_rice NG020006 385.0198551
04/04/2021 local_rice NG021006 373.823132
04/04/2021 local_rice NG020007 484.2053413
04/04/2021 local_rice NG020008 359.3935806
04/04/2021 local_rice NG021007 353.6156045
04/04/2021 local_rice NG021008 378.1871792
04/04/2021 local_rice NG021009 387.2898271
04/04/2021 local_rice NG021010 317.7764771
04/04/2021 local_rice NG020009 400.6413871
04/04/2021 local_rice NG020010 350.8766674
04/04/2021 local_rice NG020011 229.2244298
04/04/2021 local_rice NG021011 339.4917639
04/04/2021 local_rice NG021012 330.6837624
04/04/2021 local_rice NG020012 407.9777664
04/04/2021 local_rice NG021013 402.9517871
04/04/2021 local_rice NG021014 348.0097185
04/04/2021 local_rice NG020013 364.2464053
04/04/2021 local_rice NG020014 418.7499592
04/04/2021 local_rice NG020015 360.938317
04/04/2021 local_rice NG020016 350.4084329
04/04/2021 local_rice NG020017 375.72284
04/04/2021 local_rice NG020018 427.3577787
04/04/2021 local_rice NG020019 366.9704695
04/04/2021 local_rice NG021015 339.4269696
04/04/2021 local_rice NG021016 336.4246695
04/04/2021 local_rice NG020020 388.3874728
04/04/2021 local_rice NG021017 394.1519307
04/04/2021 local_rice NG021018 344.7673375
04/04/2021 local_rice NG021019 341.0985795
04/04/2021 local_rice NG021020 352.5840756
04/04/2021 local_rice NG020021 451.686015
04/04/2021 local_rice NG020022 372.5480642
04/04/2021 local_rice NG021021 416.9292449
04/04/2021 local_rice NG020023 413.1212566
04/04/2021 local_rice NG020024 285.1784935
04/04/2021 local_rice NG020025 382.6852787
04/04/2021 local_rice NG020026 342.855628
04/04/2021 local_rice NG020027 391.6584643
04/04/2021 local_rice NG021022 393.6701502
04/04/2021 local_rice NG021023 390.734382
04/04/2021 local_rice NG020028 330.6206827
04/04/2021 local_rice NG021024 379.6972674
04/04/2021 local_rice NG020029 436.934722
04/04/2021 local_rice NG021025 359.5709573
04/04/2021 local_rice NG021026 370.7826172
04/04/2021 local_rice NG021027 389.0357557
04/04/2021 local_rice NG021028 364.390563
04/04/2021 local_rice NG020030 394.8899018
04/04/2021 local_rice NG021029 354.6026948
04/04/2021 local_rice NG020031 450.8422956
04/04/2021 local_rice NG020032 395.4807888
04/04/2021 local_rice NG021030 368.8909271
04/04/2021 local_rice NG020033 345.542072
04/04/2021 local_rice NG020034 368.6961538
04/04/2021 local_rice NG021031 362.4843737
04/04/2021 local_rice NG021032 351.5487247
04/04/2021 local_rice NG021033 333.1110479
04/04/2021 local_rice NG020035 352.4340719
04/04/2021 local_rice NG020036 376.2629423
04/04/2021 local_rice NG020037 383.4869235
04/04/2021 local_rice NG020038 428.4209467
04/04/2021 local_rice NG020039 348.4337737
04/04/2021 local_rice NG020040 379.4867464
04/04/2021 local_rice NG020041 311.566191
04/04/2021 local_rice NG020042 386.7846334
04/04/2021 local_rice NG020043 398.7175982
04/04/2021 local_rice NG020044 385.876016
04/04/2021 local_rice NG021034 340.200124
04/04/2021 white_beans NG020001 364.9078403
04/04/2021 white_beans NG020002 405.0176459
04/04/2021 white_beans NG020003 355.6559092
04/04/2021 white_beans NG021001 367.8924441
04/04/2021 white_beans NG021002 339.8849381
04/04/2021 white_beans NG021003 404.0443164
04/04/2021 white_beans NG021004 322.449294
04/04/2021 white_beans NG020004 373.4328204
04/04/2021 white_beans NG020005 340.3411411
04/04/2021 white_beans NG021005 371.7665644
04/04/2021 white_beans NG020006 385.0198551
04/04/2021 white_beans NG021006 373.823132
04/04/2021 white_beans NG020007 484.2053413
04/04/2021 white_beans NG020008 359.3935806
04/04/2021 white_beans NG021007 353.6156045
04/04/2021 white_beans NG021008 378.1871792
04/04/2021 white_beans NG021009 387.2898271
04/04/2021 white_beans NG021010 317.7764771
04/04/2021 white_beans NG020009 400.6413871
04/04/2021 white_beans NG020010 350.8766674
04/04/2021 white_beans NG020011 229.2244298
04/04/2021 white_beans NG021011 339.4917639
04/04/2021 white_beans NG021012 330.6837624
04/04/2021 white_beans NG020012 407.9777664
04/04/2021 white_beans NG021013 402.9517871
04/04/2021 white_beans NG021014 348.0097185
04/04/2021 white_beans NG020013 364.2464053
04/04/2021 white_beans NG020014 418.7499592
04/04/2021 white_beans NG020015 360.938317
04/04/2021 white_beans NG020016 350.4084329
04/04/2021 white_beans NG020017 375.72284
04/04/2021 white_beans NG020018 427.3577787
04/04/2021 white_beans NG020019 366.9704695
04/04/2021 white_beans NG021015 339.4269696
04/04/2021 white_beans NG021016 336.4246695
04/04/2021 white_beans NG020020 388.3874728
04/04/2021 white_beans NG021017 394.1519307
04/04/2021 white_beans NG021018 344.7673375
04/04/2021 white_beans NG021019 341.0985795
04/04/2021 white_beans NG021020 352.5840756
04/04/2021 white_beans NG020021 451.686015
04/04/2021 white_beans NG020022 372.5480642
04/04/2021 white_beans NG021021 416.9292449
04/04/2021 white_beans NG020023 413.1212566
04/04/2021 white_beans NG020024 285.1784935
04/04/2021 white_beans NG020025 382.6852787
04/04/2021 white_beans NG020026 342.855628
04/04/2021 white_beans NG020027 391.6584643
04/04/2021 white_beans NG021022 393.6701502
04/04/2021 white_beans NG021023 390.734382
04/04/2021 white_beans NG020028 330.6206827
04/04/2021 white_beans NG021024 379.6972674
04/04/2021 white_beans NG020029 436.934722
04/04/2021 white_beans NG021025 359.5709573
04/04/2021 white_beans NG021026 370.7826172
04/04/2021 white_beans NG021027 389.0357557
04/04/2021 white_beans NG021028 364.390563
04/04/2021 white_beans NG020030 394.8899018
04/04/2021 white_beans NG021029 354.6026948
04/04/2021 white_beans NG020031 450.8422956
04/04/2021 white_beans NG020032 395.4807888
04/04/2021 white_beans NG021030 368.8909271
04/04/2021 white_beans NG020033 345.542072
04/04/2021 white_beans NG020034 368.6961538
04/04/2021 white_beans NG021031 362.4843737
04/04/2021 white_beans NG021032 351.5487247
04/04/2021 white_beans NG021033 333.1110479
04/04/2021 white_beans NG020035 352.4340719
04/04/2021 white_beans NG020036 376.2629423
04/04/2021 white_beans NG020037 383.4869235
04/04/2021 white_beans NG020038 428.4209467
04/04/2021 white_beans NG020039 348.4337737
04/04/2021 white_beans NG020040 379.4867464
04/04/2021 white_beans NG020041 311.566191
04/04/2021 white_beans NG020042 386.7846334
04/04/2021 white_beans NG020043 398.7175982
04/04/2021 white_beans NG020044 385.876016
04/04/2021 white_beans NG021034 340.200124