I can't select a column in the same line when sorting traffic data by time

Screen Link: (Learn data science with Python and R projects)

My Code:
I get a error if I try to select the date_time column like this.

daytime = traffic.loc[(traffic['date_time'].dt.hour>=7) & (traffic['date_time'].dt.hour<19), traffic['date_time']] 

I can select the date_time column like this though but I don’t understand why the previous code doesn’t work.

daytime['date_time']

What I expected to happen:
I thought I would be able to select the ‘date_time’ column on the same line when filtering through the rows.

What actually happened:
I get a KeyError if I try to do it that way.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-40-dc5b41c1b310> in <module>
      1 traffic['date_time'] = pd.to_datetime(traffic['date_time'])
----> 2 daytime = traffic.loc[(traffic['date_time'].dt.hour>=7) & (traffic['date_time'].dt.hour<19),traffic['date_time']]
      3 nighttime = traffic.loc[(traffic['date_time'].dt.hour>=19) | (traffic['date_time'].dt.hour<7)]
      4 

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in __getitem__(self, key)
   1760                 except (KeyError, IndexError, AttributeError):
   1761                     pass
-> 1762             return self._getitem_tuple(key)
   1763         else:
   1764             # we by definition only have the 0th axis

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in _getitem_tuple(self, tup)
   1287                 continue
   1288 
-> 1289             retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
   1290 
   1291         return retval

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis)
   1952                     raise ValueError("Cannot index with multidimensional key")
   1953 
-> 1954                 return self._getitem_iterable(key, axis=axis)
   1955 
   1956             # nested tuple slicing

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in _getitem_iterable(self, key, axis)
   1593         else:
   1594             # A collection of keys
-> 1595             keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
   1596             return self.obj._reindex_with_indexers(
   1597                 {axis: [keyarr, indexer]}, copy=True, allow_dups=True

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
   1550             keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr)
   1551 
-> 1552         self._validate_read_indexer(
   1553             keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
   1554         )

/dataquest/system/env/python3/lib/python3.8/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
   1638             if missing == len(indexer):
   1639                 axis_name = self.obj._get_axis_name(axis)
-> 1640                 raise KeyError(f"None of [{key}] are in the [{axis_name}]")
   1641 
   1642             # We (temporarily) allow for some missing keys with .loc, except in

KeyError: "None of [DatetimeIndex(['2012-10-02 09:00:00', '2012-10-02 10:00:00',\n               '2012-10-02 11:00:00', '2012-10-02 12:00:00',\n               '2012-10-02 13:00:00', '2012-10-02 14:00:00',\n               '2012-10-02 15:00:00', '2012-10-02 16:00:00',\n               '2012-10-02 17:00:00', '2012-10-02 18:00:00',\n               ...\n               '2018-09-30 15:00:00', '2018-09-30 15:00:00',\n               '2018-09-30 16:00:00', '2018-09-30 17:00:00',\n               '2018-09-30 18:00:00', '2018-09-30 19:00:00',\n               '2018-09-30 20:00:00', '2018-09-30 21:00:00',\n               '2018-09-30 22:00:00', '2018-09-30 23:00:00'],\n              dtype='datetime64[ns]', length=48204, freq=None)] are in the [columns]"

I would recommend checking out the documentation for loc[].

Check out the examples and see how they index by a column and then compare it to your code.