0

I am trying to write a Python code which opens a csv file with a list of books, its authors, genre etc, and allows the user to input an ISBN number and based on that it displays the results that match the search.

The csv file has 500 rows and 7 columns separated by comma.

That's my code. Now, the code only shows as output: [1 rows x 7 columns]. But it should display each infomation of the row that matched the ISBN.

# Filter ISBN
df = pd.read_csv('csv_file')
print(df.loc[df['ISBN'].str.contains("3775738193")])
0

1 Answer 1

1

You can filter in an easier way:

print(df[df["ISBN"] == "3775738193"])
Sign up to request clarification or add additional context in comments.

8 Comments

The output is still [1 rows x 8 columns] instead of displaying the entire row with all the info about the book.
Can you maybe add an example of your data in the csv?
Of course :) "ISBN,ISBN Image,Thumbnail Image,Title,Author(s),Genre ID,Genre" (these are the titles, then you have 500 rows like that alined with the collumns, like the following) 0,1467122459,1467122459.jpg,ecx.images-amazon.com/images/I/51PSyW3NE5L.jpg,Virginia Aviation (Images of Aviation),Roger Connor,0,Arts & Photography
The filtering should work with the code and it shows the whole row, correct? What is the info, which is missing?
It is not showing the whole row. That's the problem.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.