Skip to content

Instantly share code, notes, and snippets.

@socratesk
Last active November 17, 2018 18:37
Show Gist options
  • Save socratesk/c7c170924c571187df74df2d521ed848 to your computer and use it in GitHub Desktop.
Save socratesk/c7c170924c571187df74df2d521ed848 to your computer and use it in GitHub Desktop.
import pandas as pd
managerDF = pd.DataFrame({'id':[101, 102, 103, 104, 105, 106, 107, 108],
'managerId':['D025', 'A010', 'C020', 'A010', 'D025', 'D025','A010', 'D025']})
managerDF['managerIdCount'] = managerDF['managerId'].map(managerDF.groupby('managerId').size())
managerDF.drop(['managerId'], axis=1, inplace=True)
print(managerDF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment