[SciPy-User] find particular day_of_week

Robert Ferrell ferrell at diablotech.com
Wed Jan 27 16:37:46 EST 2010


On Jan 27, 2010, at 2:25 PM, josef.pktd at gmail.com wrote:

> On Wed, Jan 27, 2010 at 4:18 PM, Robert Ferrell <ferrell at diablotech.com 
> > wrote:
>> I have a time series, I want to operate (read only) on all the items
>> with a particular day_of_week.  What is an efficient way to get at
>> those?
>>
>> I've tried:
>>
>>                desiredDates = [dt for dt in myTS.dates if  
>> dt.day_of_week ==
>> day_of_week]
>>
>>                 desiredSeries = myTS[desiredDates]
>>
>> but that seems quite slow.  The second line is the one which is  
>> taking
>> all the time.  Is there a faster way?  I don't need a copy, just a
>> view, if that helps.
>
> I think numpy-discussion jan 20th  "dates, np.where finding months"
> answers this.
>

You're right, of course.  I thought this sounded familiar, but I  
couldn't think of the right search terms.

Luckily, I came up with a solution I like even better just after I  
sent this email:

	desiredSeries = myTS[myTS.day_of_week == day_of_week]

-robert



More information about the SciPy-User mailing list