I want to do calculations on three columns of a dataframe df
. In order to do that I want run a price of assets (cryptocurrencies) list in a three column table i
In your loop for i,column in enumerate(column_by_search):
you iterate over the elements in your column_by_search
list, that is column takes on the values "BTC", "ETH", "DASH" in turn. Thus, len(column)
will give you the length of the string "BTC", which is 3 in fact.
Try df[column]
instead, that will return a list with the elements in the desired column and you can iterate over it.