0

How can I select a value from a pandas dataframe by using column name and row name?

I have a table with column names as well as row names. However, I can use columnname to select a whole column but I don't kno whow to use row names in order to select a value from a cell. I want to avoid using indices as I want to trat the table like a dictionary.

MScott
  • 103
  • 1
  • 4
  • 2
    `df.loc[row_label, col_label]`, or is there something different you need (If so please edit the question to make it clear exactly what the problem is). As it stands, it's likely a duplicate of: https://stackoverflow.com/questions/44890713/selection-with-loc-in-python – ALollz Jul 21 '20 at 16:36
  • 1
    yep, that worked. So I had a table. I first had to declare the first column as index column using doing: df=df.set_index('first_column') – MScott Jul 21 '20 at 16:45

0 Answers0