You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bitwise operators are conflated with intersection, union, symmetric difference operators in NB 03.01 #429
The example output for indA & indB resulting in Index([0, 3, 5, 7, 9]) confirms that the bitwise AND is operating element-wise on the underlying data rather than treating the index as a set. I can submit a PR to update the text in NB 03.01 to explicitly state that &, |, and ^ perform element-wise arithmetic rather than set operations to prevent this common misconception.
The documentation should be updated to note that &, |, and ^ are now strictly bitwise operations in Pandas 1.0+ and explicitly recommend using intersection(), union(), and symmetric_difference() to avoid the misleading results shown in the example.
Hi, I added a small note explaining the behavior of the & operator with numeric indexes and why intersection() is useful for finding common elements. I thought this would make the example a little clearer for beginners. Please let me know if any changes are needed. Thanks!
The behavior demonstrated in the example confirms that Pandas has shifted away from using bitwise operators for set logic, as noted by @christianfrei791. Since & currently performs a bitwise AND on the underlying integer representations rather than a set intersection, the text should explicitly warn that these operators are now unsafe for set operations in modern Pandas versions. Should we update the notebook to replace these bitwise examples with the explicit intersection, union, and symmetric_difference methods to avoid misleading readers who might be running current environments?
The documentation should explicitly note that while & and | perform bitwise operations on pd.Index objects, true set operations now require the intersection and union methods to avoid the unexpected behavior demonstrated in the example.
Activity
ollasavana8 commentedon Sep 4, 2026
The example output for
indA & indBresulting inIndex([0, 3, 5, 7, 9])confirms that the bitwise AND is operating element-wise on the underlying data rather than treating the index as a set. I can submit a PR to update the text in NB 03.01 to explicitly state that&,|, and^perform element-wise arithmetic rather than set operations to prevent this common misconception.wafir645fcqs49 commentedon Sep 16, 2026
christianfrei791 commentedon Sep 19, 2026
This change stems from Pandas 1.0+, which deprecated set operations via
&,|, and `bsoua8745s12 commentedon Sep 20, 2026
heenll68 commentedon Oct 14, 2026
The documentation should be updated to note that
&,|, and^are now strictly bitwise operations in Pandas 1.0+ and explicitly recommend usingintersection(),union(), andsymmetric_difference()to avoid the misleading results shown in the example.ShreyasSwasti commentedon Oct 19, 2026
Hi, I added a small note explaining the behavior of the
&operator with numeric indexes and whyintersection()is useful for finding common elements. I thought this would make the example a little clearer for beginners. Please let me know if any changes are needed. Thanks!fragrantauto commentedon Nov 1, 2026
The behavior demonstrated in the example confirms that Pandas has shifted away from using bitwise operators for set logic, as noted by @christianfrei791. Since
¤tly performs a bitwise AND on the underlying integer representations rather than a set intersection, the text should explicitly warn that these operators are now unsafe for set operations in modern Pandas versions. Should we update the notebook to replace these bitwise examples with the explicitintersection,union, andsymmetric_differencemethods to avoid misleading readers who might be running current environments?yhdhvyfhv commentedon Nov 4, 2026
The documentation should explicitly note that while
&and|perform bitwise operations onpd.Indexobjects, true set operations now require theintersectionandunionmethods to avoid the unexpected behavior demonstrated in the example.