0

Hi I am trying to identify the lag variable for a set of groups in a python Sframe.

The code I am using is:

sf['lag'] = sf.groupby(['Group'])['Num'].shift(1)

However I am getting the error:

TypeError: groupby() takes at least 3 arguments (2 given)

AlBlue
  • 23,254
  • 14
  • 71
  • 91
MJS
  • 1
  • 1
  • If you use the editing tools you can ensure that the code examples are formatted correctly. You can also format the errors as a separate message. Also, you don't need to end with "Thanks in advance" or similar. – AlBlue Jun 03 '16 at 14:46

1 Answers1

1

You need to indicate which aggregation functions you would like thegroupby operator to do. For example

import sframe
import sframe.aggregate as agg

grp = sf.groupby(key_columns='Group', 
                 operations={'count': agg.COUNT('Group')})

Check out the documentation at https://dato.com/products/create/docs/generated/graphlab.SFrame.groupby.html#graphlab.SFrame.groupby

papayawarrior
  • 1,027
  • 7
  • 10