Repository: pandas-dev/pandas

Issue:
Indexing TimeSeries by date string drops last day
```
>>> import pandas as pd
>>> pd.__version__
'0.12.0.dev'
>>> index = pd.date_range(start='2013-05-31 00:00', end='2013-05-31 23:00', freq='H')
>>> series = pd.Series(range(len(index)), index=index)
>>> print series.index.summary()
DatetimeIndex: 24 entries, 2013-05-31 00:00:00 to 2013-05-31 23:00:00
Freq: H
>>> print series['2013-05'].index.summary()
DatetimeIndex: 1 entries, 2013-05-31 00:00:00 to 2013-05-31 00:00:00
Freq: H
```

I would expect the slice to be the same as the original series.



Discussion:

Resolving patch:
diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py
--- a/pandas/tseries/index.py
+++ b/pandas/tseries/index.py
@@ -1075,16 +1075,16 @@ def _partial_date_slice(self, reso, parsed, use_lhs=True, use_rhs=True):
 
         if reso == 'year':
             t1 = Timestamp(datetime(parsed.year, 1, 1), tz=self.tz)
-            t2 = Timestamp(datetime(parsed.year, 12, 31), tz=self.tz)
+            t2 = Timestamp(datetime(parsed.year, 12, 31, 23, 59, 59, 999999), tz=self.tz)
         elif reso == 'month':
             d = tslib.monthrange(parsed.year, parsed.month)[1]
             t1 = Timestamp(datetime(parsed.year, parsed.month, 1), tz=self.tz)
-            t2 = Timestamp(datetime(parsed.year, parsed.month, d), tz=self.tz)
+            t2 = Timestamp(datetime(parsed.year, parsed.month, d, 23, 59, 59, 999999), tz=self.tz)
         elif reso == 'quarter':
             qe = (((parsed.month - 1) + 2) % 12) + 1  # two months ahead
             d = tslib.monthrange(parsed.year, qe)[1]   # at end of month
             t1 = Timestamp(datetime(parsed.year, parsed.month, 1), tz=self.tz)
-            t2 = Timestamp(datetime(parsed.year, qe, d), tz=self.tz)
+            t2 = Timestamp(datetime(parsed.year, qe, d, 23, 59, 59, 999999), tz=self.tz)
         elif (reso == 'day' and (self._resolution < Resolution.RESO_DAY or not is_monotonic)):
             st = datetime(parsed.year, parsed.month, parsed.day)
             t1 = Timestamp(st, tz=self.tz)


Test patch:
diff --git a/pandas/tseries/tests/test_timeseries.py b/pandas/tseries/tests/test_timeseries.py
--- a/pandas/tseries/tests/test_timeseries.py
+++ b/pandas/tseries/tests/test_timeseries.py
@@ -236,6 +236,22 @@ def test_indexing(self):
         result = df['2001']['A']
         assert_series_equal(expected,result)
 
+        # GH3546 (not including times on the last day)
+        idx = date_range(start='2013-05-31 00:00', end='2013-05-31 23:00', freq='H')
+        ts  = Series(range(len(idx)), index=idx)
+        expected = ts['2013-05']
+        assert_series_equal(expected,ts)
+
+        idx = date_range(start='2013-05-31 00:00', end='2013-05-31 23:59', freq='S')
+        ts  = Series(range(len(idx)), index=idx)
+        expected = ts['2013-05']
+        assert_series_equal(expected,ts)
+
+        idx = [ Timestamp('2013-05-31 00:00'), Timestamp(datetime(2013,5,31,23,59,59,999999))]
+        ts  = Series(range(len(idx)), index=idx)
+        expected = ts['2013']
+        assert_series_equal(expected,ts)
+
 def assert_range_equal(left, right):
     assert(left.equals(right))
     assert(left.freq == right.freq)