daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mdf = pd.DataFrame([[1,2,50],[1,2,30],[1,5,10],[2,8,80]], columns=['src','dst','n']); mdf
  2.  
  3.     src dst n
  4. 0   1   2   50
  5. 1   1   2   30
  6. 2   1   5   10
  7. 3   2   8   80
  8.    
  9. test = mdf.groupby(['src','dst'])['n'].agg(['sum','count']); test
  10.  
  11.  
  12.         sum count
  13. src dst        
  14. 1   2   80  2
  15.     5   10  1
  16. 2   8   80  1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top