Re: [Tutor] using datetime and calculating hourly average

2009-07-08 Thread John [H2O]
Sanders, The problem is I don't want date, I want the date AND hour, just not minutes. As for the comparison, in numpy here's what happens when I change the way I construct the where statements: -- 196 ind = np.where( (t1 Y[:,0] t2) ) #same result with/without inner parens 197

Re: [Tutor] using datetime and calculating hourly average

2009-07-08 Thread Alan Gauld
John [H2O] washa...@gmail.com wrote -- 196 ind = np.where( (t1 Y[:,0] t2) ) #same result TypeError: can't compare datetime.datetime to numpy.ndarray Have you checked what you are comparing? Try printing Y[:,0] It looks like an invalid test and no amolunt of parenthesising or

[Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
Here's a function I wrote to calculate hourly averages: It seems a bit slow, however... any thoughts on how to improve it? def calc_hravg(X): Calculates hourly average from input data X_hr = [] minX = X[:,0].min() hr = dt.datetime(*minX.timetuple()[0:4]) while hr =

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread bob gailer
John [H2O] wrote: Here's a function I wrote to calculate hourly averages: It seems a bit slow, however... any thoughts on how to improve it? def calc_hravg(X): Calculates hourly average from input data X_hr = [] minX = X[:,0].min() hr = dt.datetime(*minX.timetuple()[0:4])

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
The data is just x,y data where x = datetime objects from the datetime module. y are just floats. It is bundled in a numpy array. So the only import statements are: import datetime as dt import numpy as np I pass the array X, where X is a numpy array of shape [n,2] where n is the number of

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Alan Gauld
John [H2O] washa...@gmail.com wrote The data is just x,y data where x = datetime objects from the datetime module. y are just floats. It is bundled in a numpy array. So the only import statements are: import datetime as dt import numpy as np I pass the array X, where X is a numpy array of

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Skipper Seabold
On Tue, Jul 7, 2009 at 6:16 AM, John [H2O]washa...@gmail.com wrote: Here's a function I wrote to calculate hourly averages: It seems a bit slow, however... any thoughts on how to improve it? def calc_hravg(X):    Calculates hourly average from input data    X_hr = []    minX =

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread John [H2O]
Alan Gauld wrote: I assume there is a good reason to use a numpy array instead of a regular list? ie You need a numpy array elsewhere in the code? I've never used numpy bt there is a possibility that array access is slower than list access, but I have no idea. It just adds an extra

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Sander Sweers
2009/7/7 John [H2O] washa...@gmail.com: The data is just x,y data where x = datetime objects from the datetime module. y are just floats. It is bundled in a numpy array. I might be totally off but, did know that you can compare datetime objects? from datetime import datetime d1 =

Re: [Tutor] using datetime and calculating hourly average

2009-07-07 Thread Alan Gauld
John [H2O] washa...@gmail.com wrote ind = np.where( (X[:,0] hr) (X[:,0] nhr) ) I have no idea what this is doing but do you really mean a bitwise and here? You are effectively bitwise anding two boolean values which seems odd to put it mildly... Well, effectively I am searching