Python numpy or pandas equivalent of the R function sweep()

前端 未结 3 2105
夕颜
夕颜 2021-01-14 01:14

What is numpy or pandas equivalent of the R function sweep()?

To elaborate: in R lets say we have a coefficient vector (say be

3条回答
  •  死守一世寂寞
    2021-01-14 01:42

    Does this work faster?

    t(t(data) * beta)
    

    Some other great answers here with profiling Multiply rows of matrix by vector?

    and finally to answer your query about numpy. Use this reference (search for Matrix Multiplication) http://mathesaurus.sourceforge.net/r-numpy.html

提交回复
热议问题