Jupyter中的Python

I have a dataframe 500 rows long by 4 columns. I need to find the proper python code that would divide the current row by the row below and then multiply that value by the value in the last row for every value in each column. I need to replicate this excel formula basically

评论
  • 哭着高兴%
    哭着高兴% 回复

    It's not clear if your data is stored in an array as provided by Numpy, were it true you'd write, with the original data contained in a

    b = a[-1]*(a[:-1]/a[+1:])
    

    a[-1] is the last row, a[:-1] the array without the last row and a[+1:] the array without the first (index zero, that is) row