1

I have a csv, like this (no headers):

a1   b1  3
a2   b2  5 
a3   b3  8

I want to get all rows, where values in last column is >4. How can I do that?

P.S. This is why this is not duplicated question - in the link above columns are named, my columns are unnamed.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Chiefir
  • 2,561
  • 1
  • 27
  • 46
  • @jezrael explain please how can I use that answer in my case? I have already seen it but did not get how to use it in my case - in that case columns are named, my columns are unnamed. – Chiefir Jul 12 '18 at 09:20
  • Sorry, reopened. – jezrael Jul 12 '18 at 09:22

1 Answers1

1

You can use boolean indexing with iloc for select last column:

df = df[df.iloc[:, -1] > 4]
print (df)
    0   1  2
1  a2  b2  5
2  a3  b3  8

Detail:

print (df.iloc[:, -1])
0    3
1    5
2    8
Name: 2, dtype: int64
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252