Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- df = pd.DataFrame(
- {'runid' : [26 , 26 , 26 , 26 , 26 , 26 , 27 , 27 , 27 , 27 , 27 , 27 ],
- 'time' : [0 , 1 , 1 , 3 , 5 , 7 , 0 , 0 , 0 , 2 , 4 , 5 ],
- 'process': ['p1', 'p2', 'p2', 'p1', 'p1', 'p2', 'p1', 'p1', 'p2', 'p2', 'p2', 'p1'],
- 'state' : ['a' , 'a' , 'b' , 'b' , 'c' , 'c' , 'a' , 'b' , 'a' , 'b' , 'c' , 'c' ]
- })
- data = pd.pivot_table(df, index=['runid', 'process'], columns=['state'], values=['time'])
- time
- state a b c
- runid process
- 26 p1 0 3 5
- p2 1 1 7
- 27 p1 0 0 5
- p2 0 2 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement