October 2019
Beginner to intermediate
674 pages
16h 43m
English
The align() function takes two objects, reindexes both objects based on a join condition (inner, outer, and so on), and returns a tuple with both objects:
s1 = pd.Series([5,6,7,8,9], index = ["a","b","c","d","e"])s2 = pd.Series([1,2,3,4,5], index = ["d","b","g","f","a"])s1.align(s2, join="outer")
The following is the output:

Since the alignment was based on an outer join, the indexes that were found in both series are found in the output. For an inner join, only the common indexes are returned, such as a, b, and d:
s1.align(s2, join="inner")
The following is the output:
Read now
Unlock full access