Home > database >  Select specific rows/columns xls file
Select specific rows/columns xls file

Time:11-26

I would like to select specific rows and columns in Python. I already use pandas somewhere in my code so I'd prefer a way to do it with this library.

I tried specific_row = pandas.read_excel('this_file.xls', "Entrees")[3] and specific_row = pandas.read_excel('this_file.xls', "Entrees", index_col = 2)[3] but I can't seem to achieve it.

CodePudding user response:

you can use the "iloc" method and special which rows to select

specific_row = pandas.read_excel('this_file.xls', "Entrees").iloc[:3,:] #select 3 rows and every column
  • Related