title: A value is trying to be set on a copy of a slice from a DataFrame. - pandas
body: <p>I'm new to <code>pandas</code>, and, given a data frame, I was trying to drop some columns that don't accomplish an specific requirement. Researching how to do it, I got to this structure:</p>
  
  <pre><code>df = df.loc[df['DS_FAMILIA_PROD'].isin(['CARTOES', 'CARTÕES'])]
  </code></pre>
  
  <p>However, when processing the frame, I get this error:</p>
  
  <pre><code>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
  
  See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
    self[name] = value
  </code></pre>
  
  <p>I'm not sure about what to do because I'm already using the <code>.loc</code> function.
  What am I missing?</p>
  
  <pre><code>f = ['ID_manifest', 'issue_date', 'channel', 'product', 'ID_client', 'desc_manifest']
  
  df = pd.DataFrame(columns=f)
  for chunk in df2017_chunks:
      aux = preProcess(chunk, f)
      df = pd.concat([df, aux])
  
  def preProcess(df, f):    
      stops = list(stopwords.words("portuguese"))
      stops.extend(['reclama', 'cliente', 'santander', 'cartao', 'cartão'])
  
      df = df.loc[df['DS_FAMILIA_PROD'].isin(['CARTOES', 'CARTÕES'])]
  
      df.columns = f
      df.desc_manifest = df.desc_manifest.str.lower() # All lower case
      df.desc_manifest = df.desc_manifest.apply(lambda x: re.sub('[^A-zÀ-ÿ]', ' ', str(x))) # Just letters
      df.replace(['NaN', 'nan'], np.nan, inplace = True) # Remone nan
      df.dropna(subset=['desc_manifest'], inplace=True)
      df.desc_manifest = df.desc_manifest.apply(lambda x: [word for word in str(x).split() if word not in stops]) # Remove stop words
  
      return df
  </code></pre>