"John [H2O]" 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 'and'ing will mak
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
"John [H2O]" 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 the array for v
2009/7/7 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.
I might be totally off but, did know that you can compare datetime objects?
>>> from datetime import datetime
>>> d1 = datetime.now()
>>> d
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
On Tue, Jul 7, 2009 at 6:16 AM, 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()
"John [H2O]" 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 shape [n,2] where n
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 poin
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])
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
10 matches
Mail list logo