0

Though there are similar Q & A available and I have tried all the options given in similar question; but not been able to resolve the issue. Seems I am not very clear on error handling on this yet. Appreciate if someone can help.

a = (str['cc'] <- 0.5).shift(1) & (str['co'] <- -0.5) 
a[0] = False 
str['GL'] = a
str['LS'] = 0 
str['LS'][a] = str['KC'][a]

Though I am getting the required output, but with an exception as below.

A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy install_nbextension,

sam
  • 71
  • 1
  • 3
  • 14
  • 1
    `str.loc[a, 'LS'] = str.loc[a, 'KC']` should help, also `(str['cc'] <- 0.5).shift(1) & (str['co'] <- -0.5) ` is wrong – jezrael Feb 03 '20 at 12:45
  • And exactly error is explained in your [link](https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#evaluation-order-matters) – jezrael Feb 03 '20 at 12:48

0 Answers0