File tree 2 files changed +20
-0
lines changed
pandas/tests/indexing/multiindex
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
import pytest
3
3
4
+ import pandas as pd
4
5
from pandas import (
5
6
DataFrame ,
6
7
MultiIndex ,
@@ -73,6 +74,24 @@ def test_iloc_getitem_multiple_items():
73
74
tm .assert_frame_equal (result , expected )
74
75
75
76
77
+ def test_iloc_np_and_pd ():
78
+ # test if iloc returns the same output for numpy array input and integer array input
79
+ df = DataFrame (
80
+ data = {
81
+ "col1" : [1 , 2 , 3 , 4 ],
82
+ "col2" : [3 , 4 , 5 , 6 ],
83
+ "col3" : [6 , 7 , 8 , 9 ],
84
+ }
85
+ )
86
+ df_np = df
87
+ df_pd = df
88
+ np_arr = np .array ([1 , 2 , 3 ])
89
+ pd_arr = pd .array ([1 , 2 , 3 ])
90
+ df_np .iloc [[1 , 2 , 3 ]] = np_arr
91
+ df_pd .iloc [[1 , 2 , 3 ]] = pd_arr
92
+ tm .assert_frame_equal (df_np , df_pd )
93
+
94
+
76
95
def test_iloc_getitem_labels ():
77
96
# this is basically regular indexing
78
97
arr = np .random .randn (4 , 3 )
Original file line number Diff line number Diff line change
1
+ Subproject commit e6a65fc5852b0237bb588b00e51ea9384b8f23e4
You can’t perform that action at this time.
0 commit comments