0

So I have a dataframe that looks like this:

split_df = 
     filename  width  height  class  xmin  ymin  xmax  ymax
0  128778.JPG   5472    3648  Panel  4489   818  4915  1417
1  128778.JPG   5472    3648  Panel  3023  1278  3403  1854
2  128776.JPG   5472    3648  Panel  3369  1310  3759  1890
3  128776.JPG   5472    3648  Panel  3721  1339  4116  1919
4  128775.JPG   5472    3648  Panel  4076  1368  4476  1952

And then two lists, train_set and test_set, these are two lists like so:

train_set = ["128778.JPG", "128776.JPG"]
test_set = ["128775.JPG"]

So basically I was wondering if there's a way to split the dataframe based on these two lists kinda like this:

> train_df = split(split_df, train_set)
> train_df 
>        filename  width  height  class  xmin  ymin  xmax  ymax
    0  128778.JPG   5472    3648  Panel  4489   818  4915  1417
    1  128778.JPG   5472    3648  Panel  3023  1278  3403  1854
    2  128776.JPG   5472    3648  Panel  3369  1310  3759  1890
    3  128776.JPG   5472    3648  Panel  3721  1339  4116  1919
> test_df = split(split_df, test_set)
> test_df 

>         filename  width  height  class  xmin  ymin  xmax  ymax
    0   128775.JPG   5472    3648  Panel  4076  1368  4476  1952
PEREZje
  • 2,272
  • 3
  • 9
  • 23

0 Answers0