text_extensions_for_pandas/spanner/join.py
def contain_join(
    first_series: pd.Series,
    second_series: pd.Series,
    first_name: str = "first",
    second_name: str = "second",
):
    """
    Compute the join of two series of spans, where a pair of spans is
    considered to match if the second span is contained within the first.

    :param first_series: First set of spans to join, wrapped in a `pd.Series`
    :param second_series: Second set of spans to join. These are the ones that
        are contained within the first set where the join predicate is satisfied.
    :param first_name: Name to give the column in the returned dataframe that
        is derived from `first_series`.
    :param second_name: Column name for spans from `second_series` in the
        returned DataFrame.

    :returns: a new `pd.DataFrame` containing all pairs of spans that match
        the join predicate. Columns of the DataFrame will be named according
        to the `first_name` and `second_name` arguments.
    """
    # For now we just run overlap_join() and filter the results.
    # TODO: Factor out the blocking code so that we can avoid filtering
    #  and regenerating the index twice.
    overlap_result = overlap_join(first_series, second_series, first_name, second_name)
    mask = overlap_result[first_name].values.contains(
        overlap_result[second_name].values
    )
    return overlap_result[mask].reset_index(drop=True)

    Compute the join of two series of spans, where a pair of spans is
    considered to match if the second span is contained within the first.

    :param first_series: First set of spans to join, wrapped in a `pd.Series`
    :param second_series: Second set of spans to join. These are the ones that
        are contained within the first set where the join predicate is satisfied.
    :param first_name: Name to give the column in the returned dataframe that
        is derived from `first_series`.
    :param second_name: Column name for spans from `second_series` in the
        returned DataFrame.

    :returns: a new `pd.DataFrame` containing all pairs of spans that match
        the join predicate. Columns of the DataFrame will be named according
        to the `first_name` and `second_name` arguments.
    
Compute the join of two series of spans, where a pair of spans is
considered to match if the second span is contained within the first.
Compute the join of two series of spans where a pair of spans is considered to match if the second span is contained within the first .
def contain_join(
    first_series: pd.Series,
    second_series: pd.Series,
    first_name: str = "first",
    second_name: str = "second",
):
    overlap_result = overlap_join(first_series, second_series, first_name, second_name)
    mask = overlap_result[first_name].values.contains(
        overlap_result[second_name].values
    )
    return overlap_result[mask].reset_index(drop=True)
def contain_join ( first_series : pd . Series , second_series : pd . Series , first_name : str = "first" , second_name : str = "second" , ) : overlap_result = overlap_join ( first_series , second_series , first_name , second_name ) mask = overlap_result [ first_name ] . values . contains ( overlap_result [ second_name ] . values ) return overlap_result [ mask ] . reset_index ( drop = True )
Compute the join of two series of spans, where a pair of spans is
considered to match if the second span is contained within the first.
Compute the join of two series of spans where a pair of spans is considered to match if the second span is contained within the first .
"""
    Compute the join of two series of spans, where a pair of spans is
    considered to match if the second span is contained within the first.

    :param first_series: First set of spans to join, wrapped in a `pd.Series`
    :param second_series: Second set of spans to join. These are the ones that
        are contained within the first set where the join predicate is satisfied.
    :param first_name: Name to give the column in the returned dataframe that
        is derived from `first_series`.
    :param second_name: Column name for spans from `second_series` in the
        returned DataFrame.

    :returns: a new `pd.DataFrame` containing all pairs of spans that match
        the join predicate. Columns of the DataFrame will be named according
        to the `first_name` and `second_name` arguments.
    """ # For now we just run overlap_join() and filter the results. # TODO: Factor out the blocking code so that we can avoid filtering #  and regenerating the index twice.
a new `pd.DataFrame` containing all pairs of spans that match
the join predicate. Columns of the DataFrame will be named according
to the `first_name` and `second_name` arguments.
a new ` pd . DataFrame ` containing all pairs of spans that match the join predicate . Columns of the DataFrame will be named according to the ` first_name ` and ` second_name ` arguments .
first_series
pd.Series
First set of spans to join, wrapped in a `pd.Series`
First set of spans to join wrapped in a ` pd . Series `
second_series
pd.Series
Second set of spans to join. These are the ones that
are contained within the first set where the join predicate is satisfied.
Second set of spans to join . These are the ones that are contained within the first set where the join predicate is satisfied .
first_name
str
Name to give the column in the returned dataframe that
is derived from `first_series`.
Name to give the column in the returned dataframe that is derived from ` first_series ` .
second_name
str
Column name for spans from `second_series` in the
returned DataFrame.
Column name for spans from ` second_series ` in the returned DataFrame .