boolean indexing that can produce a view to a large pandas dataframe?

前端 未结 3 1036
暖寄归人
暖寄归人 2021-02-04 08:52

Got a large dataframe that I want to take slices of (according to multiple boolean criteria), and then modify the entries in those slices in order to change the original datafra

3条回答
  •  醉话见心
    2021-02-04 09:34

    The pandas docs have a section on Returning a view versus a copy:

    The rules about when a view on the data is returned are entirely dependent on NumPy. Whenever an array of labels or a boolean vector are involved in the indexing operation, the result will be a copy. With single label / scalar indexing and slicing, e.g. df.ix[3:6] or df.ix[:, 'A'], a view will be returned.

提交回复
热议问题