Skip to content
Advertisement

Check if Dataframe is empty and print results

I would like to go over an excel file with different stock symbols. How can I check after reading the stocks values (Open,Close,High,Low,Volume) in a dataframe with yahoo, if the dataframe is empty? In this excel list are more than 700 Symbols and some times yahoo have no data for some symbols. So I would like to exclude this symbols, when I go to the loop.

I am struggling with the following code: if df.empty = True: print (stock).

JavaScript

Advertisement

Answer

You need to change the if to:

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement