title: Pandas Error: Passing lists with missing labels
body: <h1>Sorry, I have solved this question by remodifying the source csv data with an extra column for exact_time. It is solved at the moment. Thank you for the answers Vishnudev and Anky</h1>
  <p>I have a data file &quot;main_file.csv&quot; which has data in the following format.</p>
  <pre><code>symbol,value
  apple,340
  ibm,194
  </code></pre>
  <p>When I try to use the below program to assimilate these values to its related csv files, I get an error which is shown at the end.</p>
  <pre><code>import datetime
  import pandas as pd
  
  main_list1 = ['apple', 'ibm']
  df = pd.read_csv(&quot;main_file.csv&quot;)
  df = df[df['symbol'].isin(main_list1)]
  
  gb = df.groupby('symbol')
  for name, group in gb:
      exact_time = str(datetime.datetime.now())
      with open('{}.csv'.format(name), 'a') as f:
          group.to_csv(f, header=False, index=True, columns=[exact_time, &quot;lastPrice&quot;])
  </code></pre>
  <p><strong>Expected Output:</strong></p>
  <p><strong>For the 'apple.csv':</strong></p>
  <pre><code>time,value
  2020-04-08 22:00:11.863433,340
  </code></pre>
  <p><strong>For the 'ibm.csv':</strong></p>
  <pre><code>time,value
  2020-04-08 22:00:11.863433,194
  </code></pre>
  <p>But the error I receive is as follows:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:\Testing\Trials.py&quot;, line 98, in &lt;module&gt;
      group.to_csv(f, header=False, index=True, columns=[exact_time, &quot;lastPrice&quot;])
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\generic.py&quot;, line 3202, in to_csv
      decimal=decimal,
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\io\formats\csvs.py&quot;, line 115, in __init__
      self.obj = self.obj.loc[:, cols]
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1762, in __getitem__
      return self._getitem_tuple(key)
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1289, in _getitem_tuple
      retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1954, in _getitem_axis
      return self._getitem_iterable(key, axis=axis)
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1595, in _getitem_iterable
      keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1553, in _get_listlike_indexer
      keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
    File &quot;C:\Winpy\WPy64_368\python-3.6.8.amd64\lib\site-packages\pandas\core\indexing.py&quot;, line 1655, in _validate_read_indexer
      &quot;Passing list-likes to .loc or [] with any missing labels &quot;
  KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'
  </code></pre>
  <p>Please help me fix the Passing list error.</p>