我有一個2D numpy.array,其中第一列包含datetime.datetime對象,第二列整數:如何按日期過濾numpy.ndarray?
A = array([[2002-03-14 19:57:38, 197],
[2002-03-17 16:31:33, 237],
[2002-03-17 16:47:18, 238],
[2002-03-17 18:29:31, 239],
[2002-03-17 20:10:11, 240],
[2002-03-18 16:18:08, 252],
[2002-03-23 23:44:38, 327],
[2002-03-24 09:52:26, 334],
[2002-03-25 16:04:21, 352],
[2002-03-25 18:53:48, 353]], dtype=object)
我想這樣做的是選擇所有行的具體日期,像
A[first_column.date()==datetime.date(2002,3,17)]
array([[2002-03-17 16:31:33, 237],
[2002-03-17 16:47:18, 238],
[2002-03-17 18:29:31, 239],
[2002-03-17 20:10:11, 240]], dtype=object)
我該如何做到這一點?
感謝您的見解:)
+1將我指向datetime.replate() – 2011-12-10 18:38:39