Advertisement
wagner-cipriano

python pandas resample dataframe lines to column group-pivot

Jun 7th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. from collections import OrderedDict
  2. import pandas as pd
  3.  
  4. table = OrderedDict(( \
  5.     ("MA",   ['11', '22', '33', '11', '22', '33']), \
  6.     ('TY',['IN', 'IN', 'IN', 'OUT', 'OUT', 'OUT']), \
  7.     ('TS',   ['00:00:11', '00:00:22', '00:00:33', '00:00:45', '00:00:46', '00:00:47'])))
  8.  
  9. d = pd.DataFrame(table)
  10. print '\n'*3, d
  11.  
  12. pv = d.pivot(index='MA', columns='TY', values='TS')
  13. print '\n'*3, pv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement