join
join(inner_enumerable, outer_key=lambda x: x, inner_key=lambda x: x, result_func=lambda x: x)
Returns an Enumerable
that is the result of the inner equi-join between two Enumerable
instances. This is not an executing function.
Parameters
inner_enumerable : the inner Enumerable
to join.
outer_key : lambda expression used to select the key of the outer Enumerable
that will be used for the join
inner_key : lambda expression used to select the key of the inner Enumerable
that will be used for the join
result_func : lambda expression used to create a result element from two matching elements.
Returns
An Enumerable
that has elements transformed by result_func that are obtained by performing an inner join on two sequences.
Examples
from py_linq import Enumerable
marks1 = Enumerable([{ 'course' : 'Chemistry', 'mark': 90 }, {'course': 'Biology', 'mark': 85 }])
marks2 = Enumerable([{ 'course': 'Chemistry', 'mark': 65}, {'course': 'Computer Science', 'mark': 96 }])
chem_marks = marks1.join(marks2, lambda s1: s1['course'], lambda s2: s2['course'], lambda result: result) # [({ 'course' : 'Chemistry', 'mark': 90 }, { 'course': 'Chemistry', 'mark': 65})]