2

I need to pick out a few rows in my sframe by index. Is there an equivalent graphlab command to pandas df.irow()?

user3600497
  • 1,621
  • 1
  • 18
  • 22

1 Answers1

1

There is no direct equivalent in graphlab to DataFrame.iloc (previously irow). One way to achieve the same thing is to add a column of row numbers and use the filter_by method. Suppose I want to get only the 1st and 3rd rows:

import graphlab
sf = graphlab.SFrame({'x': ['a', 'b', 'a', 'c']})
sf = sf.add_row_number('row_id')
new_sf = sf.filter_by(values=[0, 2], column_name='row_id')
papayawarrior
  • 1,027
  • 7
  • 10