Post

PythonPython

s
sri kanth

Posted on 28th February 2024|10 views

0
votes

Pandas Get Index Of Row

How to get the index of rows which columns matches a certain value in python?

I have given a data frame with a column name "my_col" I just wanted to find the indexes of that data frame in which the values oh "my_col" = True within the range (50, 1000), anyone suggest me the proper way to write a code for this.

 

Answers
P
veerubhotla sowmithri

Posted on 28th February 2024

for j in range(50,1000): 

   if df.jloc[j]['my_Col']== True: 

      print j,df.jloc[j]['my_Col']

This may work 

 

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos