SHARE
TWEET

Untitled

a guest Jun 25th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. col
  2. 1   1
  3. 2   2
  4. 3   3
  5.      
  6. i   j   val
  7. 1   1    1
  8. 1   2    2
  9. 1   3    3
  10. 2   1    2
  11. 2   2    4
  12. 2   3    6
  13. 3   1    3
  14. 3   2    6
  15. 3   3    9
  16.      
  17. df2 = pd.DataFrame(index=pd.MultiIndex.from_product([df.index, df.col])).reset_index()
  18. df2.columns = ['i', 'j']
  19. df2['val'] = df2.i * df2.j
  20.  
  21. df2
  22. Out[45]:
  23.    i  j  val
  24. 0  1  1    1
  25. 1  1  2    2
  26. 2  1  3    3
  27. 3  2  1    2
  28. 4  2  2    4
  29. 5  2  3    6
  30. 6  3  1    3
  31. 7  3  2    6
  32. 8  3  3    9
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