title: Pandas get_dummies in for loop
body: <p>I would like to convert categorical variables into dummies using <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.get_dummies.html" rel="nofollow noreferrer"><code>pandas.get_dummies</code></a> in a <code>for</code> loop.
  However, following code does not convert the dataframes.</p>
  
  <pre><code>data_cleaner = [data_train, data_val]
  for df in data_cleaner:
      df = pd.get_dummies(df, columns = categorical_fields)
  
  data_train.head() # Not changed
  </code></pre>
  
  <p>I know that an iterator in a for loop is just a temporary variable. But the modified code also didn't work.</p>
  
  <pre><code>for i in range(len(data_cleaner)):
      data_cleaner[i] = pd.get_dummies(data_cleaner[i], columns = categorical_fields)
  
  data_train.head() # Still not changed
  </code></pre>
  
  <p>Anyone can help? Do I have to manually run <code>get_dummies</code> for each dataframe? FYI, Pandas <code>get_dummies</code> doesn't provide an <code>inplace</code> option.</p>