How to do it...

Follow these steps to create a Cartesian product:

  1. Construct two Series that have indexes that are different but contain some of the same values:
>>> s1 = pd.Series(index=list('aaab'), data=np.arange(4))
>>> s1
a 0 a 1 a 2 b 3 dtype: int64

>>> s2 = pd.Series(index=list('cababb'), data=np.arange(6))
>>> s2
c 0 a 1 b 2 a 3 b 4 b 5 dtype: int64
  1. Add the two Series together to produce a Cartesian product:
>>> s1 + s2
a 1.0 a 3.0 a 2.0 a 4.0 a 3.0 a 5.0 b 5.0 b 7.0 b 8.0 c NaN dtype: float64
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.5.201