user14361602
user14361602

Reputation: 1

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

Upvotes: 0

Views: 56

Answers (1)

Helios
Helios

Reputation: 715

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()

Upvotes: 1

Related Questions