Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. df = pd.DataFrame(
  4. {'runid' : [26 , 26 , 26 , 26 , 26 , 26 , 27 , 27 , 27 , 27 , 27 , 27 ],
  5. 'time' : [0 , 1 , 1 , 3 , 5 , 7 , 0 , 0 , 0 , 2 , 4 , 5 ],
  6. 'process': ['p1', 'p2', 'p2', 'p1', 'p1', 'p2', 'p1', 'p1', 'p2', 'p2', 'p2', 'p1'],
  7. 'state' : ['a' , 'a' , 'b' , 'b' , 'c' , 'c' , 'a' , 'b' , 'a' , 'b' , 'c' , 'c' ]
  8. })
  9.  
  10. data = pd.pivot_table(df, index=['runid', 'process'], columns=['state'], values=['time'])
  11.  
  12. time
  13. state a b c
  14. runid process
  15. 26 p1 0 3 5
  16. p2 1 1 7
  17. 27 p1 0 0 5
  18. p2 0 2 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement