Divide multiple columns by another column in pandas

前端 未结 1 578
独厮守ぢ
独厮守ぢ 2020-12-02 19:56

I need to divide all but the first columns in a DataFrame by the first column.

Here\'s what I\'m doing, but I wonder if this isn\'t the \"right\" pandas way:

相关标签:
1条回答
  • 2020-12-02 20:15

    I believe df[['B','C']].div(df.A, axis=0) and df.iloc[:,1:].div(df.A, axis=0) work.

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