<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="dr = pd.date_range('20160101', '20161130', freq='4H', tz='America/New_York')
df = pd.DataFrame({'a':np.arange(len(dr)), 'b':np.arange(len(dr))}, index=dr)
dfnov_view = df.loc['2016-11']
drnov = pd.date_range('20161101', '20161130', freq='4H', tz='America/New_York')
dfnov = pd.DataFrame({'a':np.arange(len(drnov)), 'b':np.arange(len(drnov))}, index=drnov)

df == df # works
dfnov_view == dfnov_view # works
dfnov == dfnov # works

dfnov.T == dfnov.T # works
df.T == df.T # raises KeyError on master; works on 0.22
dfnov_view.T == dfnov_view.T # raises KeyError on master; works on 0.22

# KeyError stacktrace:
In [7]: dfnov_view.T == dfnov_view.T # raises KeyError
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    457         try:
--&gt; 458             return self.mapping.get_item(val.value)
    459         except KeyError:

C:\projects\pandas-dk\pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
    933
--&gt; 934     cpdef get_item(self, int64_t val):
    935         cdef khiter_t k

C:\projects\pandas-dk\pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
    939         else:
--&gt; 940             raise KeyError(val)
    941

KeyError: 1478412000000000000

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
C:\projects\pandas-dk\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2635             try:
-&gt; 2636                 return self._engine.get_loc(key)
   2637             except KeyError:

C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    429
--&gt; 430     cpdef get_loc(self, object val):
    431         if is_definitely_invalid_key(val):

C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    459         except KeyError:
--&gt; 460             raise KeyError(val)
    461         except AttributeError:

KeyError: Timestamp('2016-11-06 01:00:00-0500', tz='America/New_York')

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    457         try:
--&gt; 458             return self.mapping.get_item(val.value)
    459         except KeyError:

C:\projects\pandas-dk\pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
    933
--&gt; 934     cpdef get_item(self, int64_t val):
    935         cdef khiter_t k

C:\projects\pandas-dk\pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()
    939         else:
--&gt; 940             raise KeyError(val)
    941

KeyError: 1478412000000000000

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
&lt;ipython-input-7-495715640ebe&gt; in &lt;module&gt;()
----&gt; 1 dfnov_view.T == dfnov_view.T # raises KeyError

C:\projects\pandas-dk\pandas\core\ops.py in f(self, other)
   1558                 raise ValueError('Can only compare identically-labeled '
   1559                                  'DataFrame objects')
-&gt; 1560             return self._compare_frame(other, func, str_rep)
   1561
   1562         elif isinstance(other, ABCSeries):

C:\projects\pandas-dk\pandas\core\frame.py in _compare_frame(self, other, func, str_rep)
   4032                 return {col: func(a[col], b[col]) for col in a.columns}
   4033
-&gt; 4034             new_data = expressions.evaluate(_compare, str_rep, self, other)
   4035             return self._constructor(data=new_data, index=self.index,
   4036                                      columns=self.columns, copy=False)

C:\projects\pandas-dk\pandas\core\computation\expressions.py in evaluate(op, op_str, a, b, use_numexpr, **eval_kwargs)
    203     use_numexpr = use_numexpr and _bool_arith_check(op_str, a, b)
    204     if use_numexpr:
--&gt; 205         return _evaluate(op, op_str, a, b, **eval_kwargs)
    206     return _evaluate_standard(op, op_str, a, b)
    207

C:\projects\pandas-dk\pandas\core\computation\expressions.py in _evaluate_numexpr(op, op_str, a, b, truediv, reversed, **eval_kwargs)
    118
    119     if result is None:
--&gt; 120         result = _evaluate_standard(op, op_str, a, b)
    121
    122     return result

C:\projects\pandas-dk\pandas\core\computation\expressions.py in _evaluate_standard(op, op_str, a, b, **eval_kwargs)
     63         _store_test_result(False)
     64     with np.errstate(all='ignore'):
---&gt; 65         return op(a, b)
     66
     67

C:\projects\pandas-dk\pandas\core\frame.py in _compare(a, b)
   4030
   4031             def _compare(a, b):
-&gt; 4032                 return {col: func(a[col], b[col]) for col in a.columns}
   4033
   4034             new_data = expressions.evaluate(_compare, str_rep, self, other)

C:\projects\pandas-dk\pandas\core\frame.py in &lt;dictcomp&gt;(.0)
   4030
   4031             def _compare(a, b):
-&gt; 4032                 return {col: func(a[col], b[col]) for col in a.columns}
   4033
   4034             new_data = expressions.evaluate(_compare, str_rep, self, other)

C:\projects\pandas-dk\pandas\core\frame.py in __getitem__(self, key)
   2202             return self._getitem_multilevel(key)
   2203         else:
-&gt; 2204             return self._getitem_column(key)
   2205
   2206     def _getitem_column(self, key):

C:\projects\pandas-dk\pandas\core\frame.py in _getitem_column(self, key)
   2209         # get column
   2210         if self.columns.is_unique:
-&gt; 2211             return self._get_item_cache(key)
   2212
   2213         # duplicate columns &amp; possible reduce dimensionality

C:\projects\pandas-dk\pandas\core\generic.py in _get_item_cache(self, item)
   2193         res = cache.get(item)
   2194         if res is None:
-&gt; 2195             values = self._data.get(item)
   2196             res = self._box_item_values(item, values)
   2197             cache[item] = res

C:\projects\pandas-dk\pandas\core\internals.py in get(self, item, fastpath)
   4070
   4071             if not isna(item):
-&gt; 4072                 loc = self.items.get_loc(item)
   4073             else:
   4074                 indexer = np.arange(len(self.items))[isna(self.items)]

C:\projects\pandas-dk\pandas\core\indexes\datetimes.py in get_loc(self, key, method, tolerance)
   1555             # needed to localize naive datetimes
   1556             key = Timestamp(key, tz=self.tz)
-&gt; 1557             return Index.get_loc(self, key, method, tolerance)
   1558
   1559         if isinstance(key, time):

C:\projects\pandas-dk\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
   2636                 return self._engine.get_loc(key)
   2637             except KeyError:
-&gt; 2638                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2639
   2640         indexer = self.get_indexer([key], method=method, tolerance=tolerance)

C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    428         return algos.is_monotonic_int64(values, timelike=True)
    429
--&gt; 430     cpdef get_loc(self, object val):
    431         if is_definitely_invalid_key(val):
    432             raise TypeError

C:\projects\pandas-dk\pandas\_libs\index.pyx in pandas._libs.index.DatetimeEngine.get_loc()
    458             return self.mapping.get_item(val.value)
    459         except KeyError:
--&gt; 460             raise KeyError(val)
    461         except AttributeError:
    462             pass

KeyError: Timestamp('2016-11-06 01:00:00-0500', tz='America/New_York')
"><pre class="notranslate"><span class="pl-s1">dr</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">date_range</span>(<span class="pl-s">'20160101'</span>, <span class="pl-s">'20161130'</span>, <span class="pl-s1">freq</span><span class="pl-c1">=</span><span class="pl-s">'4H'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'America/New_York'</span>)
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'a'</span>:<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-en">len</span>(<span class="pl-s1">dr</span>)), <span class="pl-s">'b'</span>:<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-en">len</span>(<span class="pl-s1">dr</span>))}, <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">dr</span>)
<span class="pl-s1">dfnov_view</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2016-11'</span>]
<span class="pl-s1">drnov</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">date_range</span>(<span class="pl-s">'20161101'</span>, <span class="pl-s">'20161130'</span>, <span class="pl-s1">freq</span><span class="pl-c1">=</span><span class="pl-s">'4H'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'America/New_York'</span>)
<span class="pl-s1">dfnov</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'a'</span>:<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-en">len</span>(<span class="pl-s1">drnov</span>)), <span class="pl-s">'b'</span>:<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-en">len</span>(<span class="pl-s1">drnov</span>))}, <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">drnov</span>)

<span class="pl-s1">df</span> <span class="pl-c1">==</span> <span class="pl-s1">df</span> <span class="pl-c"># works</span>
<span class="pl-s1">dfnov_view</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov_view</span> <span class="pl-c"># works</span>
<span class="pl-s1">dfnov</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov</span> <span class="pl-c"># works</span>

<span class="pl-s1">dfnov</span>.<span class="pl-v">T</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov</span>.<span class="pl-v">T</span> <span class="pl-c"># works</span>
<span class="pl-s1">df</span>.<span class="pl-v">T</span> <span class="pl-c1">==</span> <span class="pl-s1">df</span>.<span class="pl-v">T</span> <span class="pl-c"># raises KeyError on master; works on 0.22</span>
<span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c"># raises KeyError on master; works on 0.22</span>

<span class="pl-c"># KeyError stacktrace:</span>
<span class="pl-v">In</span> [<span class="pl-c1">7</span>]: <span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c"># raises KeyError</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">KeyError</span>                                  <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">457</span>         <span class="pl-k">try</span>:
<span class="pl-c1">-</span><span class="pl-c1">-&gt;</span> <span class="pl-c1">458</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">mapping</span>.<span class="pl-en">get_item</span>(<span class="pl-s1">val</span>.<span class="pl-s1">value</span>)
    <span class="pl-c1">459</span>         <span class="pl-k">except</span> <span class="pl-v">KeyError</span>:

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\h<span class="pl-s1">ashtable_class_helper</span>.<span class="pl-s1">pxi</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">Int64HashTable</span>.<span class="pl-en">get_item</span>()
    <span class="pl-c1">933</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">934</span>     <span class="pl-s1">cpdef</span> <span class="pl-en">get_item</span>(<span class="pl-s1">self</span>, <span class="pl-s1">int64_t</span> <span class="pl-s1">val</span>):
    <span class="pl-c1">935</span>         <span class="pl-s1">cdef</span> <span class="pl-s1">khiter_t</span> <span class="pl-s1">k</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\h<span class="pl-s1">ashtable_class_helper</span>.<span class="pl-s1">pxi</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">Int64HashTable</span>.<span class="pl-en">get_item</span>()
    <span class="pl-c1">939</span>         <span class="pl-s1">else</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">940</span>             <span class="pl-s1">raise</span> <span class="pl-v">KeyError</span>(<span class="pl-s1">val</span>)
    <span class="pl-c1">941</span>

<span class="pl-v">KeyError</span>: <span class="pl-c1">1478412000000000000</span>

<span class="pl-v">During</span> <span class="pl-s1">handling</span> <span class="pl-s1">of</span> <span class="pl-s1">the</span> <span class="pl-s1">above</span> <span class="pl-s1">exception</span>, <span class="pl-s1">another</span> <span class="pl-s1">exception</span> <span class="pl-s1">occurred</span>:

<span class="pl-v">KeyError</span>                                  <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">ndexes</span>\b<span class="pl-s1">ase</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">method</span>, <span class="pl-s1">tolerance</span>)
   <span class="pl-c1">2635</span>             <span class="pl-k">try</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">2636</span>                 <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_engine</span>.<span class="pl-en">get_loc</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2637</span>             <span class="pl-k">except</span> <span class="pl-v">KeyError</span>:

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">429</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">430</span>     <span class="pl-s1">cpdef</span> <span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">object</span> <span class="pl-s1">val</span>):
    <span class="pl-c1">431</span>         <span class="pl-k">if</span> <span class="pl-en">is_definitely_invalid_key</span>(<span class="pl-s1">val</span>):

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">459</span>         <span class="pl-k">except</span> <span class="pl-v">KeyError</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">460</span>             <span class="pl-s1">raise</span> <span class="pl-v">KeyError</span>(<span class="pl-s1">val</span>)
    <span class="pl-c1">461</span>         <span class="pl-s1">except</span> <span class="pl-v">AttributeError</span>:

<span class="pl-v">KeyError</span>: <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-06 01:00:00-0500'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'America/New_York'</span>)

<span class="pl-v">During</span> <span class="pl-s1">handling</span> <span class="pl-s1">of</span> <span class="pl-s1">the</span> <span class="pl-s1">above</span> <span class="pl-s1">exception</span>, <span class="pl-s1">another</span> <span class="pl-s1">exception</span> <span class="pl-s1">occurred</span>:

<span class="pl-v">KeyError</span>                                  <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">457</span>         <span class="pl-k">try</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">458</span>             <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">mapping</span>.<span class="pl-en">get_item</span>(<span class="pl-s1">val</span>.<span class="pl-s1">value</span>)
    <span class="pl-c1">459</span>         <span class="pl-s1">except</span> <span class="pl-v">KeyError</span>:

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\h<span class="pl-s1">ashtable_class_helper</span>.<span class="pl-s1">pxi</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">Int64HashTable</span>.<span class="pl-en">get_item</span>()
    <span class="pl-c1">933</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">934</span>     <span class="pl-s1">cpdef</span> <span class="pl-en">get_item</span>(<span class="pl-s1">self</span>, <span class="pl-s1">int64_t</span> <span class="pl-s1">val</span>):
    <span class="pl-c1">935</span>         <span class="pl-s1">cdef</span> <span class="pl-s1">khiter_t</span> <span class="pl-s1">k</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\h<span class="pl-s1">ashtable_class_helper</span>.<span class="pl-s1">pxi</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">Int64HashTable</span>.<span class="pl-en">get_item</span>()
    <span class="pl-c1">939</span>         <span class="pl-k">else</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">940</span>             <span class="pl-s1">raise</span> <span class="pl-v">KeyError</span>(<span class="pl-s1">val</span>)
    <span class="pl-c1">941</span>

<span class="pl-v">KeyError</span>: <span class="pl-c1">1478412000000000000</span>

<span class="pl-v">During</span> <span class="pl-s1">handling</span> <span class="pl-s1">of</span> <span class="pl-s1">the</span> <span class="pl-s1">above</span> <span class="pl-s1">exception</span>, <span class="pl-s1">another</span> <span class="pl-s1">exception</span> <span class="pl-s1">occurred</span>:

<span class="pl-v">KeyError</span>                                  <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">7</span><span class="pl-c1">-</span><span class="pl-c1">495715640</span><span class="pl-s1">ebe</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c1">==</span> <span class="pl-s1">dfnov_view</span>.<span class="pl-v">T</span> <span class="pl-c"># raises KeyError</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\o<span class="pl-s1">ps</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">f</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>)
   <span class="pl-c1">1558</span>                 <span class="pl-k">raise</span> <span class="pl-v">ValueError</span>(<span class="pl-s">'Can only compare identically-labeled '</span>
   <span class="pl-c1">1559</span>                                  <span class="pl-s">'DataFrame objects'</span>)
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1560</span>             <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_compare_frame</span>(<span class="pl-s1">other</span>, <span class="pl-s1">func</span>, <span class="pl-s1">str_rep</span>)
   <span class="pl-c1">1561</span>
   <span class="pl-c1">1562</span>         <span class="pl-s1">elif</span> <span class="pl-s1">isinstance</span>(<span class="pl-s1">other</span>, <span class="pl-v">ABCSeries</span>):

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_compare_frame</span>(<span class="pl-s1">self</span>, <span class="pl-s1">other</span>, <span class="pl-s1">func</span>, <span class="pl-s1">str_rep</span>)
   <span class="pl-c1">4032</span>                 <span class="pl-k">return</span> {<span class="pl-s1">col</span>: <span class="pl-en">func</span>(<span class="pl-s1">a</span>[<span class="pl-s1">col</span>], <span class="pl-s1">b</span>[<span class="pl-s1">col</span>]) <span class="pl-k">for</span> <span class="pl-s1">col</span> <span class="pl-c1">in</span> <span class="pl-s1">a</span>.<span class="pl-s1">columns</span>}
   <span class="pl-c1">4033</span>
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">4034</span>             <span class="pl-s1">new_data</span> <span class="pl-c1">=</span> <span class="pl-s1">expressions</span>.<span class="pl-en">evaluate</span>(<span class="pl-s1">_compare</span>, <span class="pl-s1">str_rep</span>, <span class="pl-s1">self</span>, <span class="pl-s1">other</span>)
   <span class="pl-c1">4035</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_constructor</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">new_data</span>, <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">index</span>,
   <span class="pl-c1">4036</span>                                      <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">columns</span>, <span class="pl-s1">copy</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\c<span class="pl-s1">omputation</span>\e<span class="pl-s1">xpressions</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">evaluate</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>, <span class="pl-s1">use_numexpr</span>, <span class="pl-c1">**</span><span class="pl-s1">eval_kwargs</span>)
    <span class="pl-c1">203</span>     <span class="pl-s1">use_numexpr</span> <span class="pl-c1">=</span> <span class="pl-s1">use_numexpr</span> <span class="pl-c1">and</span> <span class="pl-en">_bool_arith_check</span>(<span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>)
    <span class="pl-c1">204</span>     <span class="pl-k">if</span> <span class="pl-s1">use_numexpr</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">205</span>         <span class="pl-s1">return</span> <span class="pl-en">_evaluate</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>, <span class="pl-c1">**</span><span class="pl-s1">eval_kwargs</span>)
    <span class="pl-c1">206</span>     <span class="pl-s1">return</span> <span class="pl-en">_evaluate_standard</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>)
    <span class="pl-c1">207</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\c<span class="pl-s1">omputation</span>\e<span class="pl-s1">xpressions</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_evaluate_numexpr</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>, <span class="pl-s1">truediv</span>, <span class="pl-s1">reversed</span>, <span class="pl-c1">**</span><span class="pl-s1">eval_kwargs</span>)
    <span class="pl-c1">118</span>
    <span class="pl-c1">119</span>     <span class="pl-k">if</span> <span class="pl-s1">result</span> <span class="pl-c1">is</span> <span class="pl-c1">None</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">120</span>         <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-en">_evaluate_standard</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>)
    <span class="pl-c1">121</span>
    <span class="pl-c1">122</span>     <span class="pl-k">return</span> <span class="pl-s1">result</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\c<span class="pl-s1">omputation</span>\e<span class="pl-s1">xpressions</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_evaluate_standard</span>(<span class="pl-s1">op</span>, <span class="pl-s1">op_str</span>, <span class="pl-s1">a</span>, <span class="pl-s1">b</span>, <span class="pl-c1">**</span><span class="pl-s1">eval_kwargs</span>)
     <span class="pl-c1">63</span>         <span class="pl-s1">_store_test_result</span>(<span class="pl-c1">False</span>)
     <span class="pl-c1">64</span>     <span class="pl-k">with</span> <span class="pl-s1">np</span>.<span class="pl-en">errstate</span>(<span class="pl-s1">all</span><span class="pl-c1">=</span><span class="pl-s">'ignore'</span>):
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">65</span>         <span class="pl-s1">return</span> <span class="pl-en">op</span>(<span class="pl-s1">a</span>, <span class="pl-s1">b</span>)
     <span class="pl-c1">66</span>
     <span class="pl-c1">67</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_compare</span>(<span class="pl-s1">a</span>, <span class="pl-s1">b</span>)
   <span class="pl-c1">4030</span>
   <span class="pl-c1">4031</span>             <span class="pl-k">def</span> <span class="pl-en">_compare</span>(<span class="pl-s1">a</span>, <span class="pl-s1">b</span>):
<span class="pl-c1">-&gt;</span> <span class="pl-c1">4032</span>                 <span class="pl-s1">return</span> {<span class="pl-s1">col</span>: <span class="pl-en">func</span>(<span class="pl-s1">a</span>[<span class="pl-s1">col</span>], <span class="pl-s1">b</span>[<span class="pl-s1">col</span>]) <span class="pl-k">for</span> <span class="pl-s1">col</span> <span class="pl-c1">in</span> <span class="pl-s1">a</span>.<span class="pl-s1">columns</span>}
   <span class="pl-c1">4033</span>
   <span class="pl-c1">4034</span>             <span class="pl-s1">new_data</span> <span class="pl-c1">=</span> <span class="pl-s1">expressions</span>.<span class="pl-en">evaluate</span>(<span class="pl-s1">_compare</span>, <span class="pl-s1">str_rep</span>, <span class="pl-s1">self</span>, <span class="pl-s1">other</span>)

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">dictcomp</span><span class="pl-c1">&gt;</span>(<span class="pl-c1">.0</span>)
   <span class="pl-c1">4030</span>
   <span class="pl-c1">4031</span>             <span class="pl-k">def</span> <span class="pl-s1">_compare</span>(<span class="pl-s1">a</span>, <span class="pl-s1">b</span>):
<span class="pl-c1">-&gt;</span> <span class="pl-c1">4032</span>                 <span class="pl-s1">return</span> {<span class="pl-s1">col</span>: <span class="pl-en">func</span>(<span class="pl-s1">a</span>[<span class="pl-s1">col</span>], <span class="pl-s1">b</span>[<span class="pl-s1">col</span>]) <span class="pl-k">for</span> <span class="pl-s1">col</span> <span class="pl-c1">in</span> <span class="pl-s1">a</span>.<span class="pl-s1">columns</span>}
   <span class="pl-c1">4033</span>
   <span class="pl-c1">4034</span>             <span class="pl-s1">new_data</span> <span class="pl-c1">=</span> <span class="pl-s1">expressions</span>.<span class="pl-en">evaluate</span>(<span class="pl-s1">_compare</span>, <span class="pl-s1">str_rep</span>, <span class="pl-s1">self</span>, <span class="pl-s1">other</span>)

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">__getitem__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
   <span class="pl-c1">2202</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_getitem_multilevel</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2203</span>         <span class="pl-k">else</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">2204</span>             <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_getitem_column</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2205</span>
   <span class="pl-c1">2206</span>     <span class="pl-k">def</span> <span class="pl-en">_getitem_column</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>):

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\f<span class="pl-s1">rame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-s1">_getitem_column</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
   <span class="pl-c1">2209</span>         <span class="pl-c"># get column</span>
   <span class="pl-c1">2210</span>         <span class="pl-k">if</span> <span class="pl-s1">self</span>.<span class="pl-s1">columns</span>.<span class="pl-s1">is_unique</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">2211</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_get_item_cache</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2212</span>
   <span class="pl-c1">2213</span>         <span class="pl-c"># duplicate columns &amp; possible reduce dimensionality</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\g<span class="pl-s1">eneric</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_get_item_cache</span>(<span class="pl-s1">self</span>, <span class="pl-s1">item</span>)
   <span class="pl-c1">2193</span>         <span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">cache</span>.<span class="pl-en">get</span>(<span class="pl-s1">item</span>)
   <span class="pl-c1">2194</span>         <span class="pl-k">if</span> <span class="pl-s1">res</span> <span class="pl-c1">is</span> <span class="pl-c1">None</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">2195</span>             <span class="pl-s1">values</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">_data</span>.<span class="pl-en">get</span>(<span class="pl-s1">item</span>)
   <span class="pl-c1">2196</span>             <span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_box_item_values</span>(<span class="pl-s1">item</span>, <span class="pl-s1">values</span>)
   <span class="pl-c1">2197</span>             <span class="pl-s1">cache</span>[<span class="pl-s1">item</span>] <span class="pl-c1">=</span> <span class="pl-s1">res</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">nternals</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">get</span>(<span class="pl-s1">self</span>, <span class="pl-s1">item</span>, <span class="pl-s1">fastpath</span>)
   <span class="pl-c1">4070</span>
   <span class="pl-c1">4071</span>             <span class="pl-k">if</span> <span class="pl-c1">not</span> <span class="pl-en">isna</span>(<span class="pl-s1">item</span>):
<span class="pl-c1">-&gt;</span> <span class="pl-c1">4072</span>                 <span class="pl-s1">loc</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">items</span>.<span class="pl-en">get_loc</span>(<span class="pl-s1">item</span>)
   <span class="pl-c1">4073</span>             <span class="pl-k">else</span>:
   <span class="pl-c1">4074</span>                 <span class="pl-s1">indexer</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-en">len</span>(<span class="pl-s1">self</span>.<span class="pl-s1">items</span>))[<span class="pl-en">isna</span>(<span class="pl-s1">self</span>.<span class="pl-s1">items</span>)]

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">ndexes</span>\d<span class="pl-s1">atetimes</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">method</span>, <span class="pl-s1">tolerance</span>)
   <span class="pl-c1">1555</span>             <span class="pl-c"># needed to localize naive datetimes</span>
   <span class="pl-c1">1556</span>             <span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-v">Timestamp</span>(<span class="pl-s1">key</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s1">self</span>.<span class="pl-s1">tz</span>)
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1557</span>             <span class="pl-s1">return</span> <span class="pl-v">Index</span>.<span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">method</span>, <span class="pl-s1">tolerance</span>)
   <span class="pl-c1">1558</span>
   <span class="pl-c1">1559</span>         <span class="pl-k">if</span> <span class="pl-en">isinstance</span>(<span class="pl-s1">key</span>, <span class="pl-s1">time</span>):

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\c<span class="pl-s1">ore</span>\i<span class="pl-s1">ndexes</span>\b<span class="pl-s1">ase</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>, <span class="pl-s1">method</span>, <span class="pl-s1">tolerance</span>)
   <span class="pl-c1">2636</span>                 <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_engine</span>.<span class="pl-en">get_loc</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2637</span>             <span class="pl-k">except</span> <span class="pl-v">KeyError</span>:
<span class="pl-c1">-&gt;</span> <span class="pl-c1">2638</span>                 <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">_engine</span>.<span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>.<span class="pl-en">_maybe_cast_indexer</span>(<span class="pl-s1">key</span>))
   <span class="pl-c1">2639</span>
   <span class="pl-c1">2640</span>         <span class="pl-s1">indexer</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">get_indexer</span>([<span class="pl-s1">key</span>], <span class="pl-s1">method</span><span class="pl-c1">=</span><span class="pl-s1">method</span>, <span class="pl-s1">tolerance</span><span class="pl-c1">=</span><span class="pl-s1">tolerance</span>)

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">428</span>         <span class="pl-k">return</span> <span class="pl-s1">algos</span>.<span class="pl-en">is_monotonic_int64</span>(<span class="pl-s1">values</span>, <span class="pl-s1">timelike</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
    <span class="pl-c1">429</span>
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">430</span>     <span class="pl-s1">cpdef</span> <span class="pl-en">get_loc</span>(<span class="pl-s1">self</span>, <span class="pl-s1">object</span> <span class="pl-s1">val</span>):
    <span class="pl-c1">431</span>         <span class="pl-k">if</span> <span class="pl-en">is_definitely_invalid_key</span>(<span class="pl-s1">val</span>):
    <span class="pl-c1">432</span>             <span class="pl-s1">raise</span> <span class="pl-v">TypeError</span>

<span class="pl-v">C</span>:\p<span class="pl-s1">rojects</span>\p<span class="pl-s1">andas</span><span class="pl-c1">-</span><span class="pl-s1">dk</span>\p<span class="pl-s1">andas</span>\_<span class="pl-s1">libs</span>\i<span class="pl-s1">ndex</span>.<span class="pl-s1">pyx</span> <span class="pl-c1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">_libs</span>.<span class="pl-s1">index</span>.<span class="pl-v">DatetimeEngine</span>.<span class="pl-en">get_loc</span>()
    <span class="pl-c1">458</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">mapping</span>.<span class="pl-en">get_item</span>(<span class="pl-s1">val</span>.<span class="pl-s1">value</span>)
    <span class="pl-c1">459</span>         <span class="pl-k">except</span> <span class="pl-v">KeyError</span>:
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">460</span>             <span class="pl-s1">raise</span> <span class="pl-v">KeyError</span>(<span class="pl-s1">val</span>)
    <span class="pl-c1">461</span>         <span class="pl-s1">except</span> <span class="pl-v">AttributeError</span>:
    <span class="pl-c1">462</span>             <span class="pl-s1">pass</span>

<span class="pl-v">KeyError</span>: <span class="pl-v">Timestamp</span>(<span class="pl-s">'2016-11-06 01:00:00-0500'</span>, <span class="pl-s1">tz</span><span class="pl-c1">=</span><span class="pl-s">'America/New_York'</span>)</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">On current master, if you have a DataFrame with a tz-aware DatetimeIndex in the columns, comparison can fail with a KeyError. Oddly, it appears this occurs only if the DatetimeIndex is the columns and not on the index.</p>
<p dir="auto">Based on the KeyError it appears that for some reason .loc is looking for the pre-DST change value when it should be looking at the post-DST value. Reproducing the bug requires at least 2 DST switches in the original DataFrame. DataFrames with just a single DST switch do not seem to exhibit the behavior <i>unless</i> they are views on a larger DataFrame with two switches.</p>
<p dir="auto">This is new on master; behavior doesn't occur in 0.22.</p>
<h4 dir="auto">Expected Output</h4>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/e3b87c1843ef1a2375faff737701a13ee96f4879/hovercard" href="https://github.com/pandas-dev/pandas/commit/e3b87c1843ef1a2375faff737701a13ee96f4879"><tt>e3b87c1</tt></a><br>
python: 3.6.4.final.0<br>
python-bits: 64<br>
OS: Windows<br>
OS-release: 7<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 62 Stepping 4, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.23.0.dev0+422.ge3b87c1<br>
pytest: 3.3.2<br>
pip: 9.0.1<br>
setuptools: 38.4.0<br>
Cython: 0.27.3<br>
numpy: 1.14.0<br>
scipy: 1.0.0<br>
pyarrow: 0.8.0<br>
xarray: 0.10.0<br>
IPython: 6.2.1<br>
sphinx: 1.6.6<br>
patsy: 0.5.0<br>
dateutil: 2.6.1<br>
pytz: 2017.3<br>
blosc: None<br>
bottleneck: 1.2.1<br>
tables: 3.4.2<br>
numexpr: 2.6.4<br>
feather: 0.4.0<br>
matplotlib: 2.1.2<br>
openpyxl: 2.4.10<br>
xlrd: 1.1.0<br>
xlwt: 1.3.0<br>
xlsxwriter: 1.0.2<br>
lxml: 4.1.1<br>
bs4: 4.6.0<br>
html5lib: 1.0.1<br>
sqlalchemy: 1.2.1<br>
pymysql: 0.7.11.None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: 0.1.2<br>
fastparquet: 0.1.4<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>
<p dir="auto">I'm almost positive I've filed an issue about this before, but I don't find it. This is a pretty common operation when working with panel data. You want to merge in some constant values into a DataFrame that has repeated keys but unique index.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df = pd.util.testing.makeDataFrame() # yes!
df[&quot;group&quot;] = 0
df.ix[range(0, 20, 2), &quot;group&quot;] = 1.
df[&quot;time&quot;] = np.random.randint(5, size=len(df))
df_x = pd.DataFrame(np.c_[np.r_[np.arange(5), np.arange(5)], 
                        np.repeat([0,1], 5)], 
                    columns=[&quot;time&quot;, &quot;group&quot;])
df_x[&quot;constant_info&quot;] = np.random.randn(len(df_x))

df.merge(df_x, on=[&quot;time&quot;, &quot;group&quot;])"><pre class="notranslate"><code class="notranslate">df = pd.util.testing.makeDataFrame() # yes!
df["group"] = 0
df.ix[range(0, 20, 2), "group"] = 1.
df["time"] = np.random.randint(5, size=len(df))
df_x = pd.DataFrame(np.c_[np.r_[np.arange(5), np.arange(5)], 
                        np.repeat([0,1], 5)], 
                    columns=["time", "group"])
df_x["constant_info"] = np.random.randn(len(df_x))

df.merge(df_x, on=["time", "group"])
</code></pre></div>
<p dir="auto">Where'd my index go? Where'd my sort go, so I could even recover the index?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[~/]
[65]: pd.version.version
[65]: '0.13.1-254-g150f323'"><pre class="notranslate"><code class="notranslate">[~/]
[65]: pd.version.version
[65]: '0.13.1-254-g150f323'
</code></pre></div>