Python: How to code an exponential moving average?

前端 未结 2 969
鱼传尺愫
鱼传尺愫 2021-01-06 08:50

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

2条回答
  •  悲&欢浪女
    2021-01-06 09:23

    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.

提交回复
热议问题