[SciPy-User] question about timeseries indexing

Matt Knox mattknox.ca@gmail....
Mon Mar 29 11:23:10 CDT 2010

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

> for lines 80 and 81, I would expect either an error message or 5, but not two
> different results. What is the reason for this behaviour?

The reason for this is becausee Jan 9 and 10 are Saturday and Sunday and the
series you created is "Business" frequency, so behind the scenes it is
implicitly converting those weekend dates to Friday or Monday. If we were
starting from scratch I would probably raise an error in this situation, but
for now we are preserving that behaviour. Although I am somewhat surprised that
one of the days returns the value from the preceding Friday, and the other from
the following Monday, I'll have to look at that.

> Also, more generally, is there some way to index a time series with dates so
> that I get the latest available value?

Assuming your time series is an ordered series, just index the series with -1
to get the last value. Same as for a regular numpy array.

- Matt

More information about the SciPy-User mailing list