title: Apply the same block of formatting code to multiple dataframes at once
body: <p>My raw data is in multiple datafiles that have the same format. After importing the various (10) csv files using <code>pd.read_csv(filename.csv)</code> I have a series of dataframes <code>df1</code>, <code>df2</code>, <code>df3</code> etc etc</p>
  <p>I want to perform all of the below code to each of the dataframes.</p>
  <p>I therefore created a function to do it:</p>
  <pre><code>def my_func(df):
      df = df.rename(columns=lambda x: x.strip())
      df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
      df.date = pd.to_datetime(df.date)
      df = df.join(df['long_margin'].str.split(' ', 1, expand=True).rename(columns={0:'A', 1:'B'}))
      df = df.drop(columns=['long_margin'])
      df = df.drop(columns=['cash_interest'])
      mapping = {df.columns[6]: 'daily_turnover', df.columns[7]: 'cash_interest', df.columns[8]: 'long_margin', df.columns[9]: 'short_margin'}
      df = df.rename(columns=mapping)
      
      return(df)
  </code></pre>
  <p>and then tried to call the function as follows:</p>
  <pre><code>list_of_datasets = [df1, df2, df3]
  
  for dataframe in list_of_datasets:
  
      dataframe = my_func(dataframe)
  </code></pre>
  <p>If I manually ran this code changing <code>df</code> to <code>df1</code>, <code>df2</code> etc it works, but it doesn't seem to work in my function (or the way I am calling it).</p>
  <p>What am I missing?</p>