Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. # Adding with axis='index'
  2. if True:
  3. s = pd.Series([1, 2, 3, 4])
  4. df = pd.DataFrame({
  5. 0: [10, 20, 30, 40],
  6. 1: [50, 60, 70, 80],
  7. 2: [90, 100, 110, 120],
  8. 3: [130, 140, 150, 160]
  9. })
  10.  
  11. print df
  12. print '' # Create a blank line between outputs
  13. print df.add(s, axis='index')
  14. # The functions sub(), mul(), and div() work similarly to add()
  15.  
  16. '''
  17. 0 1 2 3
  18. 0 10 50 90 130
  19. 1 20 60 100 140
  20. 2 30 70 110 150
  21. 3 40 80 120 160
  22.  
  23. 0 1 2 3
  24. 0 11 51 91 131
  25. 1 22 62 102 142
  26. 2 33 73 113 153
  27. 3 44 84 124 164
  28. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement