Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. >>> stackme
  2. State Country group1_a1 group1_b2 Test group2_a1 group2_b2
  3. 0 TX US 0.45 0.3 Test1 2 6
  4. 1 MA US 0.03 1.2 Test2 9 7
  5. 2 ON CAN 0.70 4.2 Test3 4 2
  6. >>>
  7. >>> stubnames = ['group1', 'group2']
  8. >>> i = ['State', 'Country', 'Test']
  9. >>> j = 'a-b-Label'
  10. >>> sep = '_'
  11. >>> suffix = '.+'
  12. >>>
  13. >>> pd.wide_to_long(stackme, stubnames=stubnames, i=i, j=j, sep='_', suffix=suffix)
  14. group1 group2
  15. State Country Test a-b-Label
  16. TX US Test1 a1 0.45 2
  17. b2 0.30 6
  18. MA US Test2 a1 0.03 9
  19. b2 1.20 7
  20. ON CAN Test3 a1 0.70 4
  21. b2 4.20 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement