Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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

df[df['A'] > 2]['B'] = new_val  # new_val not set in df
# rewrite it as below
df.loc[df['A'] > 2, 'B'] = new_val
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #A #set #copy #slice #Try
ADD COMMENT
Topic
Name
2+8 =