For indexing a sub-series of some TimeSeries, one can use indices that don't completely specify the moment. For example, in a Series
s = Series(randn(1000), index=pd.date_range(start='2001-01-23 00:00', periods=1000, freq='H'))
I can say s['2001-01-23'] to get a Series for all the values for that day. This, however doesn't work with datetime-like objects. E.g. for a datetime object
day = pd.Timestamp('2001-03-05').date()
for indexing the Series with s[day]
you get a single element such as
-1.0028671116269237
but for a string representation of the object s[str(day)]
you get a whole Series such as
2001-03-05 00:00:00 -1.002867
2001-03-05 01:00:00 0.416343
2001-03-05 02:00:00 -0.012255
...
2001-03-05 13:00:00 -1.140122
2001-03-05 14:00:00 0.742483
2001-03-05 15:00:00 -0.297421
Freq: H
This seems inconsistent and being able to work with objects more abstract than strings would be much nicer.
Expected behaviour
Strings aren't always very convenient, e.g. for iterating over a TimeSeries by days. It would be nice to be able to use some sort of datetime-like objects to do not-specific-enough indexing and get sub-series - be it Datetimes,Timestamps or Timespans. This would allow us to treat indices as something we can do arithmetic with, adding offsets to move freely etc.
Comment From: wesm
I agree. The whole string business was a quick and dirty way to achieve what might be more nicely accomplished with some auxiliary object that can "query" a time series. Don't know when someone will get to it though
Comment From: jorisvandenbossche
We won't change this for actual indexing inside []
(since there is no way to distinguish Timestamp('2012-01-01')
and Timestamp('2012-01-01 00:00:00')
, so closing for now. But ideas to provide other functionality to do this is always welcome.