Skip to content

Commit

Permalink
Update Cheat Sheet.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mschermann committed May 30, 2018
1 parent 21a7c87 commit f429e7e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cheat Sheet.md
Expand Up @@ -81,6 +81,12 @@ new_df = df.groupby(['COL_NAME_1','COL_NAME_2']).agg({'COL_NAME_1':'function','C

You can replace `function` with `mean` with `min`, `max`, `unique`, etc.

The following command allows you to count the number of occurences in a group.
```
new_df = df.groupby('COL_NAME_1')['COL_NAME_2'].value_counts().reset_index(name='count')
```
This tells you how often `COL_NAME_2` appears in each group of `COL_NAME_1`.

## Create dummy variables
Dummy variables help to understand the role of categorial variable. We can store the dummies back into the a dataframe.
```
Expand Down

0 comments on commit f429e7e

Please sign in to comment.