title: error running python script for data wrangling
body: <p>I am a new python user and I am trying to write a script to perform some data wrangling activities. It will be used to fetch .csv files and return some necessary outputs. The script is shown thus:</p>
  <pre><code>import pandas as pd 
  
  #Basic day granularity of .csv file (day)
  
  dfg = pd.read_csv('Henry_Hub_Natural_Gas_Spot_Price.csv', skiprows=4)
  dfg.index = pd.to_datetime(dfg[&quot;Day&quot;],format='%d/%m/%Y')
  dfg.to_csv('gas-details_day.csv', index=False) 
  
  #Other granularities and sections of the .csv file (month)
  
  dfg_month = ddfg['Henry Hub Natural Gas Spot Price Dollars per Million Btu'].resample('M').sum()
  df = pd.DataFrame(dfg_month, index=dfg_month.index.strftime(&quot;%d/%m/%Y&quot;))
  df.to_csv('gas-details_month.csv', index=True)
  </code></pre>
  <p>Then I try to run the script with the command <code>python3 hello.py</code> then the error shows thus:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/samuel/.local/lib/python3.8/site-packages/pandas/core/indexes/base.py&quot;, line 3080, in get_loc
      return self._engine.get_loc(casted_key)
    File &quot;pandas/_libs/index.pyx&quot;, line 70, in pandas._libs.index.IndexEngine.get_loc
    File &quot;pandas/_libs/index.pyx&quot;, line 101, in pandas._libs.index.IndexEngine.get_loc
    File &quot;pandas/_libs/hashtable_class_helper.pxi&quot;, line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
    File &quot;pandas/_libs/hashtable_class_helper.pxi&quot;, line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
  KeyError: 'Day'
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;hello.py&quot;, line 6, in &lt;module&gt;
      dfg.index = pd.to_datetime(dfg[&quot;Day&quot;],format='%m/%d/%Y')
    File &quot;/home/samuel/.local/lib/python3.8/site-packages/pandas/core/frame.py&quot;, line 3024, in __getitem__
      indexer = self.columns.get_loc(key)
    File &quot;/home/samuel/.local/lib/python3.8/site-packages/pandas/core/indexes/base.py&quot;, line 3082, in get_loc
      raise KeyError(key) from err
  KeyError: 'Day'
  </code></pre>
  <p>Please help, I'd really appreciate this.</p>