Skip to content

Commit 51b0306

Browse files
code sample for pandas-dev#46769
1 parent 08c32df commit 51b0306

File tree

1 file changed

+330
-0
lines changed

1 file changed

+330
-0
lines changed

bisect/46769.py

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
# BUG: Pandas Index fails with bitwise unfuncs #46769
2+
3+
import numpy as np
4+
import pandas as pd
5+
6+
print(pd.__version__)
7+
8+
pandas_idx = [
9+
pd.Int64Index(
10+
[
11+
6,
12+
5,
13+
3,
14+
6,
15+
5,
16+
6,
17+
3,
18+
7,
19+
7,
20+
7,
21+
2,
22+
2,
23+
9,
24+
4,
25+
2,
26+
7,
27+
4,
28+
4,
29+
7,
30+
2,
31+
2,
32+
8,
33+
3,
34+
9,
35+
9,
36+
5,
37+
4,
38+
2,
39+
4,
40+
8,
41+
9,
42+
3,
43+
7,
44+
4,
45+
6,
46+
1,
47+
3,
48+
6,
49+
7,
50+
7,
51+
6,
52+
4,
53+
2,
54+
4,
55+
6,
56+
5,
57+
1,
58+
9,
59+
6,
60+
2,
61+
9,
62+
1,
63+
5,
64+
4,
65+
7,
66+
2,
67+
1,
68+
1,
69+
7,
70+
7,
71+
3,
72+
4,
73+
6,
74+
1,
75+
1,
76+
5,
77+
6,
78+
3,
79+
7,
80+
3,
81+
7,
82+
2,
83+
1,
84+
2,
85+
8,
86+
7,
87+
3,
88+
1,
89+
9,
90+
5,
91+
7,
92+
7,
93+
2,
94+
1,
95+
5,
96+
6,
97+
2,
98+
3,
99+
4,
100+
2,
101+
2,
102+
6,
103+
2,
104+
4,
105+
8,
106+
2,
107+
8,
108+
2,
109+
2,
110+
2,
111+
],
112+
dtype="int64",
113+
),
114+
pd.Int64Index(
115+
[
116+
5,
117+
6,
118+
3,
119+
1,
120+
8,
121+
3,
122+
7,
123+
2,
124+
8,
125+
8,
126+
7,
127+
5,
128+
5,
129+
3,
130+
5,
131+
2,
132+
8,
133+
5,
134+
6,
135+
2,
136+
1,
137+
7,
138+
9,
139+
6,
140+
6,
141+
7,
142+
2,
143+
1,
144+
5,
145+
3,
146+
7,
147+
3,
148+
4,
149+
3,
150+
1,
151+
8,
152+
8,
153+
8,
154+
1,
155+
2,
156+
8,
157+
3,
158+
3,
159+
3,
160+
2,
161+
2,
162+
5,
163+
5,
164+
9,
165+
1,
166+
4,
167+
5,
168+
8,
169+
3,
170+
3,
171+
9,
172+
3,
173+
9,
174+
9,
175+
5,
176+
1,
177+
6,
178+
8,
179+
2,
180+
1,
181+
6,
182+
5,
183+
7,
184+
9,
185+
4,
186+
8,
187+
6,
188+
5,
189+
8,
190+
8,
191+
7,
192+
2,
193+
6,
194+
4,
195+
1,
196+
4,
197+
7,
198+
2,
199+
4,
200+
4,
201+
7,
202+
2,
203+
3,
204+
8,
205+
1,
206+
4,
207+
1,
208+
2,
209+
3,
210+
3,
211+
9,
212+
6,
213+
8,
214+
1,
215+
1,
216+
],
217+
dtype="int64",
218+
),
219+
]
220+
221+
result = np.bitwise_and(*pandas_idx)
222+
print(result)
223+
224+
expected = pd.Int64Index(
225+
[
226+
4,
227+
4,
228+
3,
229+
0,
230+
0,
231+
2,
232+
3,
233+
2,
234+
0,
235+
0,
236+
2,
237+
0,
238+
1,
239+
0,
240+
0,
241+
2,
242+
0,
243+
4,
244+
6,
245+
2,
246+
0,
247+
0,
248+
1,
249+
0,
250+
0,
251+
5,
252+
0,
253+
0,
254+
4,
255+
0,
256+
1,
257+
3,
258+
4,
259+
0,
260+
0,
261+
0,
262+
0,
263+
0,
264+
1,
265+
2,
266+
0,
267+
0,
268+
2,
269+
0,
270+
2,
271+
0,
272+
1,
273+
1,
274+
0,
275+
0,
276+
0,
277+
1,
278+
0,
279+
0,
280+
3,
281+
0,
282+
1,
283+
1,
284+
1,
285+
5,
286+
1,
287+
4,
288+
0,
289+
0,
290+
1,
291+
4,
292+
4,
293+
3,
294+
1,
295+
0,
296+
0,
297+
2,
298+
1,
299+
0,
300+
8,
301+
7,
302+
2,
303+
0,
304+
0,
305+
1,
306+
4,
307+
7,
308+
2,
309+
0,
310+
4,
311+
6,
312+
2,
313+
3,
314+
0,
315+
0,
316+
0,
317+
0,
318+
2,
319+
0,
320+
0,
321+
0,
322+
0,
323+
0,
324+
0,
325+
0,
326+
],
327+
dtype="int64",
328+
)
329+
330+
pd.testing.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)