-1

I have a excel workbook that I convert into a dataframe but I'm trying to rea each row and column and assign variables but the problem is the data is not always in the same place so I can't hardcode the location of the data. So I capture the first row and first column and I'm just trying to search them to find the data and get the location.

Here is my code:

wb = load_workbook(strTotalFile,data_only = True)       
for sheet in wb.sheetnames:
    ws = wb[sheet]
    data = ws.values

    pd.set_option('display.max_columns', None)
    df = pd.DataFrame(data)
    mainRow = df.iloc[[17]]

    mainCol = df.iloc[:,1]
user13470314
  • 27
  • 1
  • 8
  • Your actual question isn't clear. Please [edit] to provide a [mcve] with a sample of your input data, a sample of your current output, and an example of your desired output, so that we can better understand how to help. See [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – G. Anderson Oct 15 '21 at 17:30
  • Read with headers = None then you can deal with numeric row and column numbers. – Tarik Oct 15 '21 at 17:38
  • @Tarik wrong question it's updated now. – user13470314 Oct 15 '21 at 17:52

1 Answers1

0

This part of your question really bothers me:

" the data is not always in the same place "

I am taking this to mean that your columns are not formatted, or rows. This would cause no end of problems for you.

But assuming I am wrong, you can just essentially use simple commands, The accepted answer I link below covers what you need, not my answer.

How do I select rows from a DataFrame based on column values?