title: Script keep showing "SettingCopyWithWarning'
body: <p>Hello my problem is that my script keep showing below message </p>
  
  <hr>
  
  <p>SettingWithCopyWarning: 
  A value is trying to be set on a copy of a slice from a DataFrame</p>
  
  <p>See the caveats in the documentation: <a href="https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy" rel="nofollow noreferrer">https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy</a>
    downcast=downcast</p>
  
  <hr>
  
  <p>I Searched the google for a while regarding this, and it seems like my code is somehow 
  assigning sliced dataframe to new variable, which is problematic. </p>
  
  <p>The problem is ** I can't find where my code get problematic **
  I tried copy function, or seperated the nested functions, but it is not working </p>
  
  <p>I attached my code below. </p>
  
  <pre><code>def case_sorting(file_get, col_get, methods_get, operator_get, value_get):
  
  ops = {"&gt;": gt, "&lt;": lt}
  col_get = str(col_get)
  value_get = int(value_get)
  
  if methods_get is "|x|":
      new_file = file_get[ops[operator_get](file_get[col_get], value_get)]
  else:
      new_file = file_get[ops[operator_get](file_get[col_get], np.percentile(file_get[col_get], value_get))]
  return new_file
  </code></pre>
  
  <p>Basically what i was about to do was to make flask api that gets excel file as an input, and returns the csv file with some filtering. So I defined some functions first. </p>
  
  <pre><code>def get_brandlist(df_input, brand_input):
  if brand_input == "default":
      final_list = (pd.unique(df_input["브랜드"])).tolist()
  else:
      final_list = brand_input.split("/")
  if '브랜드' in final_list:
      final_list.remove('브랜드')
  final_list = [x for x in final_list if str(x) != 'nan']
  return final_list
  </code></pre>
  
  <p>Then I defined the main function </p>
  
  <pre><code>def select_bestitem(df_data, brand_name, col_name, methods, operator, value):
  
  # // 2-1 // to remove unnecessary rows and columns with na values
  df_data = df_data.dropna(axis=0 &amp; 1, how='all')
  df_data.fillna(method='pad', inplace=True)
  
  # // 2-2 // iterate over all rows to find which row contains brand value
  default_number = 0
  for row in df_data.itertuples():
      if '브랜드' in row:
          df_data.columns = df_data.iloc[default_number, :]
          break
      else:
          default_number = default_number + 1
  
  # // 2-3 // create the list contains all the target brand names
  brand_list = get_brandlist(df_input=df_data, brand_input=brand_name)
  
  # // 2-4 // subset the target brand into another dataframe
  df_data_refined = df_data[df_data.iloc[:, 1].isin(brand_list)]
  
  # // 2-5 // split the dataframe based on the "brand name", and apply the input condition
  df_per_brand = {}
  df_per_brand_modified = {}
  for brand_each in brand_list:
      df_per_brand[brand_each] = df_data_refined[df_data_refined['브랜드'] == brand_each]
      file = df_per_brand[brand_each].copy()
      df_per_brand_modified[brand_each] = case_sorting(file_get=file, col_get=col_name, methods_get=methods,
                                                       operator_get=operator, value_get=value)
  
  # // 2-6 // merge all the remaining dataframe
  df_merged = pd.DataFrame()
  for brand_each in brand_list:
      df_merged = df_merged.append(df_per_brand_modified[brand_each], ignore_index=True)
  final_df = df_merged.to_csv(index=False, sep=',', encoding='utf-8')
  return final_df
  </code></pre>
  
  <p>And I am gonna import this function in my app.py later </p>
  
  <p>I am quite new to all the coding, therefore really really sorry if my code is quite hard to understand, but I just really wanted to get rid of this annoying warning message. Thanks for help in advance :) </p>