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.stack.imgur.com/3mbA7.png

Robert Riley
  • 389
  • 1
  • 7
  • 31
  • I don't want to see a snapshot, I want a [mcve]. Sadly, you've neglected to attach even the promised screenshot. – cs95 Jun 25 '18 at 03: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. – Robert Riley Jun 25 '18 at 03: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. – cs95 Jun 25 '18 at 03:29

1 Answers1

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
U13-Forward
  • 69,221
  • 14
  • 89
  • 114