Reading a Python Data Frame

I will attach an image below, but first, let me describe what I am trying to achieve here. First of all, I am writing a program which reads a csv, puts it into a pandas data frame, and then once that data frame is created, we are trying to search for a specific value in the data frame. Lets sat column 2 in the data frame deals with the names of students, how would we search for the students name, and return the row of information about this student?

Now, in terms of what we are actually trying to do. We are dealing with stock info, and we are trying to read the data frame to where you enter the company name, the program searches the data frame, finds that company name, and will return info in a different column (stock symbols) but same row.

Why won’t this code search the data frame for the keyword? What is wrong? How would you all go about searching for a specific company name in the data frame and return the stock symbol (different column, same row)



For starters, you might want to head over to the Pandas documentation and brush up on navigating through DataFrames.

As it is, each reference in your function to row is actually referencing a column.

Your currently does the following:

  1. Reads the csv and assigns it to a DataFrame called symbols
  2. Loops through each column in symbols and checks if keyword is in the second row of that column.
  3. If it is, the function prints the first row of that column.

Also, do you know the names of the columns you are looking through? If you do, your function will be pretty straightforward.