pandas: Divide DataFrame last row by first row

前端 未结 2 1659
离开以前
离开以前 2021-01-24 00:09

This questions is similar to Python: Pandas Divide DataFrame by first row

I have a DataFrame which looks like this:

            1125400  5430095  1095751         


        
相关标签:
2条回答
  • 2021-01-24 00:47

    A clearer way is to use iloc:

    df.iloc[0] / df.iloc[-1]
    
    0 讨论(0)
  • 2021-01-24 00:52

    Just take the first row and the last row values, then divide them, like this: df.T[df.index[0]] / df.T[df.index[-1]]

    0 讨论(0)
提交回复
热议问题