范例如下
https://imgur.com/vaZab8V
如果我今天要找出Store 1中的Cost
df.loc["Store 1"]["Cost"]
老师说用这种方法好像会出现问题因此不建议
原文如下:
This looks pretty reasonable and gets us the result we wanted. But chaining
can come with some costs and is best avoided if you can use another approach.
In particular, chaining tends to cause Pandas to return a copy of the
DataFrame instead of a view on the DataFrame. For selecting a data, this is
not a big deal, though it might be slower than necessary. If you are changing
data though, this is an important distinction and can be a source of error.
想请教大家,老师在这边讲的具体上来说是什么问题?
小的有点看不懂这样的方法会带来什么状况@@
不知道是否有前辈可以帮忙指点一二?