Skip to Content
Numerical Computing with Python
book

Numerical Computing with Python

by Pratap Dangeti, Allen Yu, Claire Chung, Aldrin Yim
December 2018
Beginner to intermediate
682 pages
18h 1m
English
Packt Publishing
Content preview from Numerical Computing with Python

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))>>> s1a    0
a    1
a    2
b    3
dtype: int64>>> s2 = pd.Series(index=list('cababb'), data=np.arange(6))>>> s2c    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 + s2a    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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Numerical Computing with NumPy

Mastering Numerical Computing with NumPy

Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu

Publisher Resources

ISBN: 9781789953633OtherOtherErrata Page