[SciPy-User] question about timeseries indexing

Matt Knox mattknox.ca@gmail....
Mon Mar 29 14:45:08 CDT 2010


Christian Prinoth <christian <at> prinoth.name> writes:

> Sorry, I was referring to a situation where I want the latest available value
> _before_ a given date. for example, If I do
> 
> series[sunday]
> 
> I want it to return the value from series[friday]

Then in that case it would be better to explicitly convert the date and specify
the behaviour you want.

For example:

input_date_D = ts.Date('D', '2010-01-10')
input_date_B = input_date_D.asfreq('B', 'BEFORE')
value = series[input_date_B]

In the case where input_date_D is already a week day, input_date_B will end up
being the same as the original input date, if input_date_D was a weekend, it
would be converted to the Friday before.

- Matt




More information about the SciPy-User mailing list