@@ -179,6 +179,32 @@ def test_usecols_str(self, ext):
179
179
tm .assert_frame_equal (df2 , df1 , check_names = False )
180
180
tm .assert_frame_equal (df3 , df1 , check_names = False )
181
181
182
+ @pytest .mark .parametrize ("columns,usecols,parse_cols" , [
183
+ (['A' , 'B' , 'C' ], ['A:D' ], ['A:D' ]),
184
+ (['B' , 'C' ], ['A' , 'C' , 'D' ], ['A' , 'C' , 'D' ]),
185
+ (['B' , 'C' ], ['A' , 'C:D' ], ['A' , 'C:D' ])
186
+ ])
187
+ # GH18273 - read_excel return empty dataframe when using usecols as a list
188
+ # of strings
189
+ def test_usecols_str_list (self , ext , columns , usecols , parse_cols ):
190
+
191
+ dfref = self .get_csv_refdf ('test1' )
192
+
193
+ df1 = dfref .reindex (columns = columns )
194
+ df2 = self .get_exceldf ('test1' , ext , 'Sheet1' , index_col = 0 ,
195
+ usecols = usecols )
196
+ df3 = self .get_exceldf ('test1' , ext , 'Sheet2' , skiprows = [1 ],
197
+ index_col = 0 , usecols = usecols )
198
+
199
+ with tm .assert_produces_warning (FutureWarning ):
200
+ df4 = self .get_exceldf ('test1' , ext , 'Sheet2' , skiprows = [1 ],
201
+ index_col = 0 , parse_cols = parse_cols )
202
+
203
+ # TODO add index to xls, read xls ignores index name ?
204
+ tm .assert_frame_equal (df2 , df1 , check_names = False )
205
+ tm .assert_frame_equal (df3 , df1 , check_names = False )
206
+ tm .assert_frame_equal (df4 , df1 , check_names = False )
207
+
182
208
def test_excel_stop_iterator (self , ext ):
183
209
184
210
parsed = self .get_exceldf ('test2' , ext , 'Sheet1' )
0 commit comments