I have a dataset with multiple columns but only focusing on one column called 'VAL'. Every value in this column ranges from 0 to 4 so I would like to split this into 5 separate data frames based on those duplicate values and then export each of these data frames into individual csv files.
I have been able to sort the numbers using pandas but now I need to divide up the values into smaller datasets keeping in mind that I have multiple files I would like to do this to so possibly a for loop?
this is what I currently have as an output
A B C D E F G VAL FILE
954 380 158 166 431 201 769 0 001.csv
1142 348 203 962 0 878 1023 0 001.csv
1688 279 229 0 488 1007 0 0 001.csv
4792 371 420 29 372 0 745 0 001.csv
2106 352 76 196 388 0 695 0 001.csv
... ... ... ... ... ... ... ...
5634 441 283 277 788 45 585 4 001.csv
827 672 606 24 1023 463 742 4 001.csv
6703 324 203 0 623 214 726 4 001.csv
9056 604 398 0 981 0 633 4 001.csv
0 574 338 144 942 608 793 4 001.csv
this is what I would like it to relatively look like
A B C D E F G VAL FILE
954 380 158 166 431 201 769 0 val_0.csv
1142 348 203 962 0 878 1023 0 val_0.csv
1688 279 229 0 488 1007 0 0 val_0.csv
4792 371 420 29 372 0 745 0 val_0.csv
2106 352 76 196 388 0 695 0 val_0.csv
A B C D E F G VAL FILE
5634 441 283 277 788 45 585 4 val_4.csv
827 672 606 24 1023 463 742 4 val_4.csv
6703 324 203 0 623 214 726 4 val_4.csv
9056 604 398 0 981 0 633 4 val_4.csv
0 574 338 144 942 608 793 4 val_4.csv
