python pandas dataframe, is it pass-by-value or pass-by-reference

后端 未结 6 879
陌清茗
陌清茗 2020-12-02 05:58

If I pass a dataframe to a function and modify it inside the function, is it pass-by-value or pass-by-reference?

I run the following code

a = pd.Data         


        
6条回答
  •  粉色の甜心
    2020-12-02 06:36

    The question isn't PBV vs. PBR. These names only cause confusion in a language like Python; they were invented for languages that work like C or like Fortran (as the quintessential PBV and PBR languages). It is true, but not enlightening, that Python always passes by value. The question here is whether the value itself is mutated or whether you get a new value. Pandas usually errs on the side of the latter.

    http://nedbatchelder.com/text/names.html explains very well what Python's system of names is.

提交回复
热议问题