title: Python: How can I read csv and clean my data in a loop
body: <p>I have the following code below which reads in csv and cleans them for 5 different financial assets. The code seems repetitive and inefficient. Is there a way I can do this in a <strong>loop</strong> instead of having to declare the 5 assets variables one-by-one?</p>
  
  <pre><code>import pandas as pd
  
  # Input symbols
  stock_symbol = "VTI"
  ltb_symbol = "TLT"
  stb_symbol = "IEI"
  gld_symbol = "GLD"
  comms_symbol = "DBC"
  
  session_type = "open" # open, high, low or close
  
  # Read csv for all symbols in Dataframes
  stock_df = pd.read_csv("BATS_{}, 1D.csv".format(stock_symbol))
  ltb_df = pd.read_csv("BATS_{}, 1D.csv".format(ltb_symbol))
  stb_df = pd.read_csv("BATS_{}, 1D.csv".format(stb_symbol))
  gld_df = pd.read_csv("BATS_{}, 1D.csv".format(gld_symbol))
  comms_df = pd.read_csv("BATS_{}, 1D.csv".format(comms_symbol))
  
  #Clean Dataframes
  stock_df = stock_df.rename({'{}'.format(session_type): '{}'.format(stock_symbol)}, axis=1)\
              .loc[:,['time','{}'.format(stock_symbol)]]
  ltb_df = ltb_df.rename({'{}'.format(session_type): '{}'.format(ltb_symbol)}, axis=1)\
              .loc[:,['time','{}'.format(ltb_symbol)]]
  stb_df = stb_df.rename({'{}'.format(session_type): '{}'.format(stb_symbol)}, axis=1)\
              .loc[:,['time','{}'.format(stb_symbol)]]
  gld_df = gld_df.rename({'{}'.format(session_type): '{}'.format(gld_symbol)}, axis=1)\
              .loc[:,['time','{}'.format(gld_symbol)]]
  comms_df = comms_df.rename({'{}'.format(session_type): '{}'.format(comms_symbol)}, axis=1)\
              .loc[:,['time','{}'.format(comms_symbol)]]
  </code></pre>