範例如下
如果我今天要找出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.
想請教大家,老師在這邊講的具體上來說是什麼問題?
小的有點看不懂這樣的方法會帶來什麼狀況@@
不知道是否有前輩可以幫忙指點一二?