import pandas as pd
data = {
"code": ["12", "13", "14"],
"value": range(3)
}
df = pd.DataFrame(data=data)
# res = df[["code"]].copy() # filt_col+copy后无需reset_index 但filt_col必须copy
# res.iloc[0, 0] = 0
# res = df.iloc[[-1, 0]] # filt_row 无需copy 不会warning
# res.iloc[0, 0] = 0
# res = df.query("code != '13'") # 同上
# res.iloc[0, 0] = 0
# 什么时候需要reset_index 才能避免warning?