I have the following dataset.
- 1 2
- 2 5
- 3 4
- 4 7
- 6 8
- 7 6
My aim is to have a count of numbers in column 2 which are less than or equal 6. The numbers in column 2 which are less than or equal to 6 are 2,4,5 and 6. So, i want the output to be 4 as 2,4,5 and 6 are all appearing once, so total appearance count=4.
My approach has been:
import numpy as np
data=np.loadtxt('/Users/Hrihaan/Desktop/A.txt')
x=data[:,1]
Count=list(x.flatten()).count(6) #it only counts the number of times 6 appears in the list.
Any suggestion on how to manipulate the code to get a count for numbers equal or less than 6 would mean a lot.