简体   繁体   中英

pandas error: value is trying to be set on a copy of a slice from a DataFrame

df_play = pd.read_csv("players_stats_by_season_full_details.csv")

VC = df_play[df_play["League"] == "NBA"]
VC

VC["FT_Miss"] = VC['FTA'] - VC['FTM']

the error message:

A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

VC is not dataframe, its a slice of the original, meaning it is just a pointer back to df_play

try;

VC = df_play[df_play["League"] == "NBA"].copy()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM