0

I've got a 6000+ row dataframe and I'd like to drop all rows that have a value less than 2. My current attempt is: df=coal[coal['Value'] > 2] and the error is: unorderable types: str() > int()

I've attached a snapshot of my df, I want to drop the values that are small. I'm still rather new with python, so please bear with me.

https://i.sstatic.net/3mbA7.png

3
  • I don't want to see a snapshot, I want a minimal reproducible example. Sadly, you've neglected to attach even the promised screenshot. Commented Jun 25, 2018 at 3:20
  • I have posted a link, as I cannot attach a screenshot yet. I do not see how this is a duplicate, as I am not asking to delete a row based on the length of a string, but simply based on the value. Commented Jun 25, 2018 at 3:28
  • You do not see how it's a duplicate because you don't know how to apply the duplicate to your problem. Just because the condition differs doesn't mean it isn't applicable. instead of comparing the string length, you compare the numeric value. Commented Jun 25, 2018 at 3:29

1 Answer 1

0

Try the below:

import pandas as pd df = pd.DataFrame({'a':[1,3,4],'b':[3,5,7]}) print(df[df>2].dropna()) 

Output:

 a b 1 3.0 5 2 4.0 7 
Sign up to request clarification or add additional context in comments.

3 Comments

Please don't answer obvious duplicates in this tag, it generally isn't considered good form.
@CallCenterExecutive such a nice name ; 0
@Dark Sorry, there was a typo in my name :p

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.