0
点赞
收藏
分享

微信扫一扫

什么时候需要reset_index 才能避免warning?

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?

举报

相关推荐

DFS什么时候需要回溯

0 条评论