title: Pandas AttributeError: 'DataFrame' object has no attribute 'Timestamp'
body: <p>so i want to get the monthly sum with my script but i always get an AttributeError, which i dont <br />understand. The column Timestamp does indeed exist on my combined_csv. <br />I know for sure that this line is causing the problem since i tested al of my other code before.<br />
  <strong>AttributeError: 'DataFrame' object has no attribute 'Timestamp'</strong><br />
  I'll appreciate every kind of help i can get - thanks</p>
  <pre><code>import os
  import glob
  import pandas as pd
  
  # set working directory
  os.chdir(&quot;Path to CSVs&quot;)
  
  # find all csv files in the folder
  # use glob pattern matching -&gt; extension = 'csv'
  # save result in list -&gt; all_filenames
  extension = 'csv'
  all_filenames = [i for i in glob.glob('*.{}'.format(extension))]
  # print(all_filenames)
  
  # combine all files in the list
  combined_csv = pd.concat([pd.read_csv(f, sep=';') for f in all_filenames])
  # Format CSV
  # Transform Timestamp column into datetime
  combined_csv['Timestamp'] = pd.to_datetime(combined_csv.Timestamp)
  # Read out first entry of every day of every month
  combined_csv = round(combined_csv.resample('D', on='Timestamp')['HtmDht_Energy'].agg(['first']))
  # To get the yield of day i have to subtract day 2 HtmDht_Energy - day 1 HtmDht_Energy
  combined_csv[&quot;dailyYield&quot;] = combined_csv[&quot;first&quot;] - combined_csv[&quot;first&quot;].shift()
  # combined_csv.reset_index()
  # combined_csv.index.set_names([&quot;year&quot;, &quot;month&quot;], inplace=True)
  combined_csv[&quot;monthlySum&quot;] = combined_csv.groupby([combined_csv.Timestamp.dt.year, combined_csv.Timestamp.dt.month]).sum()
  </code></pre>
  <p>Output of combined_csv.columns</p>
  <pre><code>Index(['Timestamp', 'teHst0101', 'teHst0102', 'teHst0103', 'teHst0104',
         'teHst0105', 'teHst0106', 'teHst0107', 'teHst0201', 'teHst0202',
         'teHst0203', 'teHst0204', 'teHst0301', 'teHst0302', 'teHst0303',
         'teHst0304', 'teAmb', 'teSolFloHexHst', 'teSolRetHexHst',
         'teSolCol0501', 'teSolCol1001', 'teSolCol1501', 'vfSol', 'prSolRetSuc',
         'rdGlobalColAngle', 'gSolPump01_roActual', 'gSolPump02_roActual',
         'gHstPump03_roActual', 'gHstPump04_roActual', 'gDhtPump06_roActual',
         'gMB01_isOpened', 'gMB02_isOpened', 'gCV01_posActual',
         'gCV02_posActual', 'HtmDht_Energy', 'HtmDht_Flow', 'HtmDht_Power',
         'HtmDht_Volume', 'HtmDht_teFlow', 'HtmDht_teReturn', 'HtmHst_Energy',
         'HtmHst_Flow', 'HtmHst_Power', 'HtmHst_Volume', 'HtmHst_teFlow',
         'HtmHst_teReturn', 'teSolColDes', 'teHstFloDes'],
        dtype='object')
  </code></pre>
  <p><strong>Traceback</strong>:<br />
  When i select it with<br />
  combined_csv[&quot;monthlySum&quot;] = combined_csv.groupby([combined_csv['Timestamp'].dt.year, combined_csv['Timestamp'].dt.month]).sum()</p>
  <pre><code>Traceback (most recent call last):
    File &quot;D:\Users\wink\PycharmProjects\csvToExcel\main.py&quot;, line 28, in &lt;module&gt;
      combined_csv[&quot;monthlySum&quot;] = combined_csv.groupby([combined_csv['Timestamp'].dt.year, combined_csv['Timestamp'].dt.month]).sum()
    File &quot;D:\Users\wink\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3024, in __getitem__
      indexer = self.columns.get_loc(key)
    File &quot;D:\Users\wink\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\indexes\base.py&quot;, line 3082, in get_loc
      raise KeyError(key) from err
  KeyError: 'Timestamp'
  </code></pre>
  <p>traceback with mustafas solution</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3862, in reindexer
      value = value.reindex(self.index)._values
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\util\_decorators.py&quot;, line 312, in wrapper
      return func(*args, **kwargs)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 4176, in reindex
      return super().reindex(**kwargs)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\generic.py&quot;, line 4811, in reindex
      return self._reindex_axes(
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 4022, in _reindex_axes
      frame = frame._reindex_index(
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 4038, in _reindex_index
      new_index, indexer = self.index.reindex(
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\indexes\multi.py&quot;, line 2492, in reindex
      target = MultiIndex.from_tuples(target)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\indexes\multi.py&quot;, line 175, in new_meth
      return meth(self_or_cls, *args, **kwargs)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\indexes\multi.py&quot;, line 531, in from_tuples
      arrays = list(lib.tuples_to_object_array(tuples).T)
    File &quot;pandas\_libs\lib.pyx&quot;, line 2527, in pandas._libs.lib.tuples_to_object_array
  ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long long'
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\main.py&quot;, line 28, in &lt;module&gt;
      combined_csv[&quot;monthlySum&quot;] = combined_csv.groupby([combined_csv.Timestamp.dt.year, combined_csv.Timestamp.dt.month]).sum()
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3163, in __setitem__
      self._set_item(key, value)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3242, in _set_item
      value = self._sanitize_column(key, value)
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3888, in _sanitize_column
      value = reindexer(value).T
    File &quot;C:\Users\winklerm\PycharmProjects\csvToExcel\venv\lib\site-packages\pandas\core\frame.py&quot;, line 3870, in reindexer
      raise TypeError(
  TypeError: incompatible index of inserted column with frame index
  </code></pre>