1

I have a huge csv file and i want to filter out the dataframes with a specific value.

dataf = pd.read_csv('table.txt', sep=',')
dataf[(dataf.Subject_code == '100')]
#print (dataf[(dataf.Subject_code =='100')])

It returns an empty data frame. I get only the headers of the file. I need all the dataframes whose subject code is equal to 100.

Student Subject_code Score 1 100 A 10 500 B 12 100 A 15 100 C

2 Answers2

1

Pandas most likely converts strings representing numbers to numbers (you can find out by doing dataf.info() and see if the column is numeric or Object. If it does, you should do equality check against 100 not "100".

Igor Rivin
  • 4,632
  • 2
  • 23
  • 35
0

Use this:

print(dataf[dataf.Subject_code == 100])
Balaji Ambresh
  • 4,977
  • 2
  • 5
  • 17