1

I have written code in Python that pulls info from Yahoo Finance, and turns in into a DataFrame using pandas. This is what it looks like when I print.

here is a snippet of the table

I would like to pull all the stocks that are under $30 from the 'Price (Intraday)' column. However I have been running into many issues.

For Example, I turned this into a .csv file and had pandas read it, however I ran into "you can't hash mutable values" problems, and also "you can't compare 'list'/'str' and 'int' variables" problems.

This is what I tried first. It only worked once, but after I ran it again for the next day's stock prices it stopped working (I think because the numbers changed aka the 'mutable' problems).

under30 = nice_data.loc(nice_data["Price (Intraday)"] < 30)

After I tried changing that, I ran into the second problem I mentioned above (list/str vs int).

I'm totally lost at this point and don't know what to do. All I would like is to find a way to pull information from the DataFrame and make a new one that only has the stock information of the stocks that are under $30. In addition, this should be able to work for different values as the stock market changes every day.

Please let me know how to do this, or even if it's possible. I'm clueless.

petezurich
  • 9,280
  • 9
  • 43
  • 57
greg
  • 11
  • 1

0 Answers0