Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Adding with axis='index'
- if True:
- s = pd.Series([1, 2, 3, 4])
- df = pd.DataFrame({
- 0: [10, 20, 30, 40],
- 1: [50, 60, 70, 80],
- 2: [90, 100, 110, 120],
- 3: [130, 140, 150, 160]
- })
- print df
- print '' # Create a blank line between outputs
- print df.add(s, axis='index')
- # The functions sub(), mul(), and div() work similarly to add()
- '''
- 0 1 2 3
- 0 10 50 90 130
- 1 20 60 100 140
- 2 30 70 110 150
- 3 40 80 120 160
- 0 1 2 3
- 0 11 51 91 131
- 1 22 62 102 142
- 2 33 73 113 153
- 3 44 84 124 164
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement