snowflake.snowpark.DataFrame.natural_join¶
- DataFrame.natural_join(right: DataFrame, how: Optional[str] = None, **kwargs) DataFrame [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/dataframe.py#L2011-L2072)¶
Performs a natural join of the specified type (
how
) with the current DataFrame and another DataFrame (right
).- Parameters:
right – The other
DataFrame
to join.how –
We support the following join types:
Inner join: “inner” (the default value)
Left outer join: “left”, “leftouter”
Right outer join: “right”, “rightouter”
Full outer join: “full”, “outer”, “fullouter”
You can also use
join_type
keyword to specify this condition. Note that to avoid breaking changes, currently whenjoin_type
is specified, it overrideshow
.
- Examples::
>>> df1 = session.create_dataframe([[1, 2], [3, 4], [5, 6]], schema=["a", "b"]) >>> df2 = session.create_dataframe([[1, 7], [3, 8]], schema=["a", "c"]) >>> df1.natural_join(df2).show() ------------------- |"A" |"B" |"C" | ------------------- |1 |2 |7 | |3 |4 |8 | -------------------
>>> df1 = session.create_dataframe([[1, 2], [3, 4], [5, 6]], schema=["a", "b"]) >>> df2 = session.create_dataframe([[1, 7], [3, 8]], schema=["a", "c"]) >>> df1.natural_join(df2, "left").show() -------------------- |"A" |"B" |"C" | -------------------- |1 |2 |7 | |3 |4 |8 | |5 |6 |NULL | --------------------