0

I have a csv that contains 1000 rows in a python code and returning a new dataframe with 3 columns:
noOfPeople and Description, Location
My final df will be like this one:

 id  companyName  noOfPeople  Description  Location
 1    comp1       75          tech         USA
 2    comp2       22          fashion      USA
 3    comp3       70          tech         USA

I want to write a code that will stop once I have 200 rows where noOfPeople is greater or equal to 70 and it will return all the rest rows empty. So the code will count columns where noOfPeople >=70. Once I have 200 rows that has this condition, the code will stop.

Can someone help?

2 Answers 2

2
df[df['noOfPeople'] >= 70].iloc[:200]
Sign up to request clarification or add additional context in comments.

Comments

1

Use head or iloc for select first 200 values and then get max: print (df1['noOfPeople'].iloc[:199].max()) And add your filter what ever you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.