Skip to content

Commit

Permalink
pandas: Split-apply-combine (2 funcs: count, mean)
Browse files Browse the repository at this point in the history
  • Loading branch information
olisteadman authored May 3, 2018
1 parent 6af8e5e commit d0fb866
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,16 @@ define({

{
'name' : 'Combining',
'snippet' : ['',],
'sub-menu' : [
{
'name' : 'Split-apply-combine (sum)',
'snippet' : ['df['label_count'] = df.groupby('label', as_index=False)['label'].transform(lambda x: x.count())',],
},
{
'name' : 'Split-apply-combine (mean)',
'snippet' : ['df['label_mean'] = df.groupby('label', as_index=False)['label'].transform(lambda x: x.mean())',],
},
],
},

{
Expand Down

2 comments on commit d0fb866

@Shi-intel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add \ in front of the ' to represent single quote.

@sjdemartini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the syntax errors above cause the SnippetsMenu to crash and fail to show up. Opened a PR with a fix here #1636

Please sign in to comment.