Repository: pandas-dev/pandas

Issue:
Slicing an index with DateTime throws AttributeError: 'int' object has no attribute 'stop'
#### Code Sample, a copy-pastable example if possible

```python

idx = pd.IndexSlice

dt_index = pd.date_range(start="1jan2019 00:15:33",periods=100,freq="h")  #this will fail
#dt_index = pd.date_range(start="1jan2019",periods=100,freq="d")    #this works

zf = pd.DataFrame(index=dt_index)
zf['foo']=10
zf['bar']="squat"
zf['zaa']=range(len(dt_index))
zf.index.name="date"
zf = zf.reset_index().set_index(["date", "bar", "zaa"])


zf.loc[idx['2019-1-1':'2019-1-3',"squat",:],:]     # This works ok
zf.loc[idx['2019-1-1':,"squat",:],:]     # This fails  AttributeError: 'int' object has no attribute 'stop'
zf.loc[idx['2019-1-1':None,'squat',:],:]           # AttributeError: 'int' object has no attribute 'stop'
```
#### Problem description

The same slice of a multindex fails if the index is DateTimes but works if the index is Dates-only.
This occurs in pandas 0.24.2

A [related-sounding ticket ](https://github.com/pandas-dev/pandas/issues/10331)said if I have a reproducible example, post a new ticket.

#### Expected Output

same output as if I'd sliced a dates-only index (provided in the example above)

#### Output of ``pd.show_versions()``

<details>

[paste the output of ``pd.show_versions()`` here below this line]
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.24.2
pytest: 4.3.1
pip: 19.0.3
setuptools: 40.8.0
Cython: 0.29.6
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: 1.8.5
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.5.1
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: 2.6.1
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.5
lxml.etree: 4.3.2
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.1
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
</details>



Discussion:
Looks like `idx` is undefined in your example.
> Looks like `idx` is undefined in your example.

Oh dear, yes.  Sorry, this is fixed in the example now.  
> Looks like `idx` is undefined in your example.

fixed example
Thanks. Looks like a bug  in https://github.com/pandas-dev/pandas/blob/cf74b0272af2e13e5b9ce40c8bf42df750ddc560/pandas/core/indexes/multi.py#L2753-L2758

It's thinking `stop` is a slice object, when it could be an int or a slice. I'd recommend something like

```
start = getattr(start, 'start', start)
stop = getattr(stop, 'stop', stop)
return convert_indexer(start, stop, step)
```

Interested in making a PR?
Yes, that sounds like an interesting thing to work on.    I guess I [follow the instructions here on pull requests](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#contributing-your-changes-to-pandas).  Anything else to be aware of ?

Resolving patch:
diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py
--- a/pandas/core/indexes/multi.py
+++ b/pandas/core/indexes/multi.py
@@ -2755,7 +2755,9 @@ def convert_indexer(start, stop, step, indexer=indexer,
                 # a partial date slicer on a DatetimeIndex generates a slice
                 # note that the stop ALREADY includes the stopped point (if
                 # it was a string sliced)
-                return convert_indexer(start.start, stop.stop, step)
+                start = getattr(start, 'start', start)
+                stop = getattr(stop, 'stop', stop)
+                return convert_indexer(start, stop, step)
 
             elif level > 0 or self.lexsort_depth == 0 or step is not None:
                 # need to have like semantics here to right


Test patch:
diff --git a/pandas/tests/indexes/multi/test_indexing.py b/pandas/tests/indexes/multi/test_indexing.py
--- a/pandas/tests/indexes/multi/test_indexing.py
+++ b/pandas/tests/indexes/multi/test_indexing.py
@@ -397,3 +397,24 @@ def test_get_indexer_categorical_time():
          Categorical(date_range("2012-01-01", periods=3, freq='H'))])
     result = midx.get_indexer(midx)
     tm.assert_numpy_array_equal(result, np.arange(9, dtype=np.intp))
+
+
+def test_timestamp_multiindex_indexer():
+    # https://github.com/pandas-dev/pandas/issues/26944
+    idx = pd.MultiIndex.from_product([
+        pd.date_range("2019-01-01T00:15:33", periods=100, freq="H",
+                      name="date"),
+        ['x'],
+        [3]
+    ])
+    df = pd.DataFrame({'foo': np.arange(len(idx))}, idx)
+    result = df.loc[pd.IndexSlice['2019-1-2':, "x", :], 'foo']
+    qidx = pd.MultiIndex.from_product([
+        pd.date_range(start="2019-01-02T00:15:33", end='2019-01-05T02:15:33',
+                      freq="H", name="date"),
+        ['x'],
+        [3]
+    ])
+    should_be = pd.Series(data=np.arange(24, len(qidx) + 24), index=qidx,
+                          name="foo")
+    tm.assert_series_equal(result, should_be)