Home > Back-end >  Accessing a particular value in a row in CSV File using another row - python
Accessing a particular value in a row in CSV File using another row - python

Time:01-22

I have a CSV file where I have 3 columns. I need to access the 3rd column with respect to the values in the 1st and 2nd columns.

For Example:

Age |  Height (cm) | Name 
______________________________
25  |   180        |  John 
25  |   175        |  Sam 
26  |   180        |  Ben 

Let's say I need to access only some particular names in the long list based on their age and height.

CodePudding user response:

Check with .loc

print(df.loc[df['Age'].eq(25) & df['Height'].eq(180), 'Name'])
  •  Tags:  
  • Related