Created
October 28, 2017 06:26
-
-
Save zhusimaji/32dbb13ba9a3ba7fc86ac7bf3522a493 to your computer and use it in GitHub Desktop.
pd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data=pd.DataFrame([[2010,'auto'],[2010,'haha'],[2011,'haha'],[2012,'md']],columns=['year','type']) | |
data['typecnt']=np.ones(data.shape[0]) | |
data.groupby(['year','type'])['typecnt'].count() | |
输出 | |
year type | |
2010 auto 1 | |
haha 1 | |
2011 haha 1 | |
2012 md 1 | |
Name: typecnt, dtype: int64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment