Skip to content

Commit ac99ebb

Browse files
IndexSeekcpcloud
authored andcommitted
docs(examples): add distinct argument example for intersect
1 parent f26b9e6 commit ac99ebb

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

ibis/expr/api.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,11 +2079,15 @@ def intersect(table: ir.Table, *rest: ir.Table, distinct: bool = True) -> ir.Tab
20792079
Table
20802080
A new table containing the intersection of all input tables.
20812081
2082+
See Also
2083+
--------
2084+
[`Table.intersect`](./expression-tables.qmd#ibis.expr.types.relations.Table.intersect)
2085+
20822086
Examples
20832087
--------
20842088
>>> import ibis
20852089
>>> ibis.options.interactive = True
2086-
>>> t1 = ibis.memtable({"a": [1, 2]})
2090+
>>> t1 = ibis.memtable({"a": [1, 2, 2]})
20872091
>>> t1
20882092
┏━━━━━━━┓
20892093
┃ a ┃
@@ -2092,15 +2096,17 @@ def intersect(table: ir.Table, *rest: ir.Table, distinct: bool = True) -> ir.Tab
20922096
├───────┤
20932097
│ 1 │
20942098
│ 2 │
2099+
│ 2 │
20952100
└───────┘
2096-
>>> t2 = ibis.memtable({"a": [2, 3]})
2101+
>>> t2 = ibis.memtable({"a": [2, 2, 3]})
20972102
>>> t2
20982103
┏━━━━━━━┓
20992104
┃ a ┃
21002105
┡━━━━━━━┩
21012106
│ int64 │
21022107
├───────┤
21032108
│ 2 │
2109+
│ 2 │
21042110
│ 3 │
21052111
└───────┘
21062112
>>> ibis.intersect(t1, t2)
@@ -2111,7 +2117,15 @@ def intersect(table: ir.Table, *rest: ir.Table, distinct: bool = True) -> ir.Tab
21112117
├───────┤
21122118
│ 2 │
21132119
└───────┘
2114-
2120+
>>> ibis.intersect(t1, t2, distinct=False)
2121+
┏━━━━━━━┓
2122+
┃ a ┃
2123+
┡━━━━━━━┩
2124+
│ int64 │
2125+
├───────┤
2126+
│ 2 │
2127+
│ 2 │
2128+
└───────┘
21152129
"""
21162130
return table.intersect(*rest, distinct=distinct) if rest else table
21172131

ibis/expr/types/relations.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ def intersect(self, table: Table, *rest: Table, distinct: bool = True) -> Table:
17181718
--------
17191719
>>> import ibis
17201720
>>> ibis.options.interactive = True
1721-
>>> t1 = ibis.memtable({"a": [1, 2]})
1721+
>>> t1 = ibis.memtable({"a": [1, 2, 2]})
17221722
>>> t1
17231723
┏━━━━━━━┓
17241724
┃ a ┃
@@ -1727,15 +1727,17 @@ def intersect(self, table: Table, *rest: Table, distinct: bool = True) -> Table:
17271727
├───────┤
17281728
│ 1 │
17291729
│ 2 │
1730+
│ 2 │
17301731
└───────┘
1731-
>>> t2 = ibis.memtable({"a": [2, 3]})
1732+
>>> t2 = ibis.memtable({"a": [2, 2, 3]})
17321733
>>> t2
17331734
┏━━━━━━━┓
17341735
┃ a ┃
17351736
┡━━━━━━━┩
17361737
│ int64 │
17371738
├───────┤
17381739
│ 2 │
1740+
│ 2 │
17391741
│ 3 │
17401742
└───────┘
17411743
>>> t1.intersect(t2)
@@ -1746,6 +1748,15 @@ def intersect(self, table: Table, *rest: Table, distinct: bool = True) -> Table:
17461748
├───────┤
17471749
│ 2 │
17481750
└───────┘
1751+
>>> t1.intersect(t2, distinct=False)
1752+
┏━━━━━━━┓
1753+
┃ a ┃
1754+
┡━━━━━━━┩
1755+
│ int64 │
1756+
├───────┤
1757+
│ 2 │
1758+
│ 2 │
1759+
└───────┘
17491760
"""
17501761
return self._assemble_set_op(ops.Intersection, table, *rest, distinct=distinct)
17511762

0 commit comments

Comments
 (0)