데이터가 숫자가 적은 배열 (.csv 파일에서 읽음)이 있습니다. np.genfromtxt의 관련 추출은 다음과 같습니다.numpy.where에서 객체 메서드에 액세스합니까?
dtype = [("Category", "|S10"),
("Status", "|S11"),
("Date_start", object),
("Date_stop", object)],
names=True,
converters={2:lambda d:datetime.strptime(d, "%d/%m/%y"),
3:lambda d:datetime.strptime(d, "%d/%m/%y")}
)
모든 것이 datetime 객체의 요소에 액세스하는 한 가지 예외와 함께 작동합니다.
print inp['Date_start'][1].month #returns 7
print np.where(inp['Category'] == '"R5"') #returns an array of matching indices
하지만 다음 코드 줄이 내가 개월 일들이 발생하는 기반으로 결과를 반환 할 수없는 의미 AttributeError: 'numpy.ndarray' object has no attribute 'month'
print np.where(inp['Date_start'].month == 7)
던졌습니다 : 코드 반환 다음 두 라인은 내가 예상 정확히 , 나는 그것을 필요로한다.
np.where에서 원하는 동작을 얻을 수있는 방법이 있습니까? 다음
def func(a):
return a.month
vfunc = np.vectorize(func)
및 사용 :
부탁드립니다. 감사합니다. –