3

ファイルからPythonにストリーミングできるデータセットがあります。pandas を使用して、asof メソッドを使用して 9:46 の時間ゼロから始まる 1 分ごとのデータの HLOC チャートを作成したいと思います。更新として pandas データフレームにデータをストリーミングする方法も知りたいです。これは可能ですか?

2012-03-15 09:45:00  139.8000
2012-03-15 09:45:11  139.7900
2012-03-15 09:45:22  139.7850
2012-03-15 09:45:33  139.8100
2012-03-15 09:45:44  139.8000
2012-03-15 09:45:55  139.8000
2012-03-15 09:46:06  139.8100
2012-03-15 09:46:16  139.8500
2012-03-15 09:46:27  139.8400
2012-03-15 09:46:38  139.8300
2012-03-15 09:46:49  139.8000
2012-03-15 09:46:59  139.8200
2012-03-15 09:47:10  139.8200
2012-03-15 09:47:21  139.8500
2012-03-15 09:47:32  139.8600
2012-03-15 09:47:42  139.8680
2012-03-15 09:47:53  139.8600
2012-03-15 09:48:04  139.8620
2012-03-15 09:48:15  139.8500
2012-03-15 09:48:25  139.8600
2012-03-15 09:48:36  139.8400
2012-03-15 09:48:47  139.8197
2012-03-15 09:48:58  139.8200
2012-03-15 09:49:08  139.8000
2012-03-15 09:49:19  139.8300
2012-03-15 09:49:30  139.8199
2012-03-15 09:49:41  139.8300
2012-03-15 09:49:52  139.8600
2012-03-15 09:50:02  139.8600
2012-03-15 09:50:13  139.8800
2012-03-15 09:50:24  139.9000
2012-03-15 09:50:35  139.9200
2012-03-15 09:50:45  139.9300
2012-03-15 09:50:56  139.9300
2012-03-15 09:51:07  139.9290
2012-03-15 09:51:18  139.9100
2012-03-15 09:51:28  139.9200
2012-03-15 09:51:39  139.9200
2012-03-15 09:51:50  139.9370
2012-03-15 09:52:01  139.9386
2012-03-15 09:52:11  139.9400
2012-03-15 09:52:22  139.9590
2012-03-15 09:52:33  139.9650
2012-03-15 09:52:44  139.9600
2012-03-15 09:52:54  139.9800
2012-03-15 09:53:05  139.9900
2012-03-15 09:53:16  139.9800
2012-03-15 09:53:27  139.9800
2012-03-15 09:53:37  139.9700
2012-03-15 09:53:48  139.9900
2012-03-15 09:53:59  139.9884
2012-03-15 09:54:10  139.9900
2012-03-15 09:54:20  139.9900
2012-03-15 09:54:31  140.0100
2012-03-15 09:54:42  140.0000
2012-03-15 09:54:53  139.9850
2012-03-15 09:55:03  139.9900
2012-03-15 09:55:14  140.0000
2012-03-15 09:55:25  140.0090
2012-03-15 09:55:36  140.0000
2012-03-15 09:55:47  139.9890
2012-03-15 09:55:57  139.9900
2012-03-15 09:56:08  139.9900
2012-03-15 09:56:19  140.0000
2012-03-15 09:56:30  140.0400
2012-03-15 09:56:40  140.0200
2012-03-15 09:56:51  140.0200
2012-03-15 09:57:02  140.0300
2012-03-15 09:57:13  140.0400
2012-03-15 09:57:23  140.0390
2012-03-15 09:57:34  140.0300
2012-03-15 09:57:45  140.0200
2012-03-15 09:57:56  140.0200
2012-03-15 09:58:06  140.0400
2012-03-15 09:58:17  140.0300
2012-03-15 09:58:28  140.0400
2012-03-15 09:58:39  140.0300
2012-03-15 09:58:49  140.0300
2012-03-15 09:59:00  140.0500
2012-03-15 09:59:11  140.0400
2012-03-15 09:59:22  140.0200
2012-03-15 09:59:32  140.0300
2012-03-15 09:59:43  140.0300
2012-03-15 09:59:54  140.0200
2012-03-15 10:00:05  140.0100
2012-03-15 10:00:15  140.0100
2012-03-15 10:00:26  140.0700
2012-03-15 10:00:37  140.0900
2012-03-15 10:00:48  140.0899
2012-03-15 10:00:58  140.0700
2012-03-15 10:01:09  140.0800
2012-03-15 10:01:20  140.0300
2012-03-15 10:01:31  140.0200
2012-03-15 10:01:41  140.0100
2012-03-15 10:01:52  139.9800
2012-03-15 10:02:03  139.9300
2012-03-15 10:02:14  139.9900
2012-03-15 10:02:25  140.0200
2012-03-15 10:02:35  140.0000
2012-03-15 10:02:46  139.9700
2012-03-15 10:02:57  139.9300
2012-03-15 10:03:08  139.9300
2012-03-15 10:03:18  139.9200
2012-03-15 10:03:29  139.9700
2012-03-15 10:03:40  139.9700
2012-03-15 10:03:51  139.9600
2012-03-15 10:04:01  139.9700
2012-03-15 10:04:12  139.9200
2012-03-15 10:04:23  139.9100
2012-03-15 10:04:34  139.9200
2012-03-15 10:04:44  139.9100
2012-03-15 10:04:55  139.9100
2012-03-15 10:05:06  139.8900
2012-03-15 10:05:17  139.9000
2012-03-15 10:05:27  139.9900
2012-03-15 10:05:38  139.9700
2012-03-15 10:05:49  139.9521
2012-03-15 10:06:00  139.9700
2012-03-15 10:06:10  139.9800
2012-03-15 10:06:21  140.0200
2012-03-15 10:06:32  140.0400
2012-03-15 10:06:43  140.0400
2012-03-15 10:06:53  140.0300
2012-03-15 10:07:04  140.0400
2012-03-15 10:07:15  139.9893
2012-03-15 10:07:26  140.0100
2012-03-15 10:07:36  140.0100
2012-03-15 10:07:47  140.0010
2012-03-15 10:07:58  139.9900
2012-03-15 10:08:09  140.0100
2012-03-15 10:08:19  139.9800
2012-03-15 10:08:30  139.9899
2012-03-15 10:08:41  140.0000
2012-03-15 10:08:52  140.0000
2012-03-15 10:09:03  139.9710
2012-03-15 10:09:13  139.9710
2012-03-15 10:09:24  139.9700
2012-03-15 10:09:35  139.9700
2012-03-15 10:09:46  139.9700
2012-03-15 10:09:56  139.9614
2012-03-15 10:10:07  139.9700
2012-03-15 10:10:18  139.9400
2012-03-15 10:10:29  139.9100
2012-03-15 10:10:39  139.9300
2012-03-15 10:10:50  139.9400
2012-03-15 10:11:01  139.9800
2012-03-15 10:11:12  140.0000
2012-03-15 10:11:22  139.9700
2012-03-15 10:11:33  139.9400
2012-03-15 10:11:44  139.8900
2012-03-15 10:11:55  139.8800
2012-03-15 10:12:05  139.9000
2012-03-15 10:12:16  139.9100
2012-03-15 10:12:27  139.9100
2012-03-15 10:12:38  139.9000
2012-03-15 10:12:48  139.9300
2012-03-15 10:12:59  139.9200
2012-03-15 10:13:10  139.9300
2012-03-15 10:13:21  139.9500
2012-03-15 10:13:31  139.9500
2012-03-15 10:13:42  139.9700
2012-03-15 10:13:53  139.9600
2012-03-15 10:14:04  139.9700
2012-03-15 10:14:14  139.9400
2012-03-15 10:14:25  140.0300
4

1 に答える 1

4

次の pandas 0.8.0 リリース (現在は git master で利用可能です。バグがあれば報告してください) では、次のことができます。

In [52]: ts.resample('T', how='ohlc')
Out[52]: 
                         open       low     high     close
2012-03-15 09:45:00  139.8000  139.8000  139.800  139.8000
2012-03-15 09:46:00  139.7900  139.7850  139.810  139.8000
2012-03-15 09:47:00  139.8100  139.8000  139.850  139.8200
2012-03-15 09:48:00  139.8200  139.8200  139.868  139.8600
2012-03-15 09:49:00  139.8620  139.8197  139.862  139.8200
2012-03-15 09:50:00  139.8000  139.8000  139.860  139.8600
2012-03-15 09:51:00  139.8600  139.8600  139.930  139.9300
2012-03-15 09:52:00  139.9290  139.9100  139.937  139.9370
2012-03-15 09:53:00  139.9386  139.9386  139.980  139.9800
2012-03-15 09:54:00  139.9900  139.9700  139.990  139.9884
2012-03-15 09:55:00  139.9900  139.9850  140.010  139.9850
2012-03-15 09:56:00  139.9900  139.9890  140.009  139.9900
2012-03-15 09:57:00  139.9900  139.9900  140.040  140.0200
2012-03-15 09:58:00  140.0300  140.0200  140.040  140.0200
2012-03-15 09:59:00  140.0400  140.0300  140.050  140.0500
2012-03-15 10:00:00  140.0400  140.0200  140.040  140.0200
2012-03-15 10:01:00  140.0100  140.0100  140.090  140.0700
2012-03-15 10:02:00  140.0800  139.9800  140.080  139.9800
2012-03-15 10:03:00  139.9300  139.9300  140.020  139.9300
2012-03-15 10:04:00  139.9300  139.9200  139.970  139.9600
2012-03-15 10:05:00  139.9700  139.9100  139.970  139.9100
2012-03-15 10:06:00  139.8900  139.8900  139.990  139.9700
2012-03-15 10:07:00  139.9800  139.9800  140.040  140.0300
2012-03-15 10:08:00  140.0400  139.9893  140.040  139.9900
2012-03-15 10:09:00  140.0100  139.9800  140.010  140.0000
2012-03-15 10:10:00  139.9710  139.9614  139.971  139.9614
2012-03-15 10:11:00  139.9700  139.9100  139.970  139.9400
2012-03-15 10:12:00  139.9800  139.8800  140.000  139.8800
2012-03-15 10:13:00  139.9000  139.9000  139.930  139.9200
2012-03-15 10:14:00  139.9300  139.9300  139.970  139.9600
2012-03-15 10:15:00  139.9700  139.9400  140.030  140.0300

OHLC プロットについては、http: //matplotlib.sourceforge.net/examples/pylab_examples/finance_demo.htmlをご覧ください。最終的には、パンダでこれに適したメソッドを追加する予定です。

于 2012-04-16T00:39:08.397 に答える