Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: pin1= pd.Series(np.random.randn(2), index=['2', '4'])
- In [2]: pin2= pd.Series(np.random.randn(3), index=['0', '1', '7'])
- In [3]: pin3=pd.merge(pin1,pin2,how='outer')
- In [4]: pin3
- Out [4]:
- 0 0.2941
- 1 0.2869
- 2 1.7098
- 3 -0.2126
- 4 0.2696
- Out [4]:
- 0 0.2941
- 1 0.2869
- 2 1.7098
- 4 -0.2126
- 7 0.2696
- pd.concat([pin1, pin2]).sort_index()
- In [3732]: pin1.combine_first(pin2)
- Out[3732]:
- 0 -0.820341
- 1 0.492719
- 2 -0.785723
- 4 -1.815021
- 7 2.027267
- dtype: float64
- In [3734]: pin1.append(pin2).sort_index()
- Out[3734]:
- 0 -0.820341
- 1 0.492719
- 2 -0.785723
- 4 -1.815021
- 7 2.027267
- dtype: float64
- In [3735]: pin1
- Out[3735]:
- 2 -0.785723
- 4 -1.815021
- dtype: float64
- In [3736]: pin2
- Out[3736]:
- 0 -0.820341
- 1 0.492719
- 7 2.027267
- dtype: float64
- pin1.align(pin2,join='outer')[0].fillna(pin1.align(pin2,join='outer')[1])
- Out[991]:
- 0 -0.278627
- 1 0.009388
- 2 -0.655377
- 4 0.564739
- 7 0.793576
- dtype: float64
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement