@@ -92,11 +92,30 @@ def test_examples2(self):
92
92
by = 'ticker' ,
93
93
tolerance = pd .Timedelta ('2ms' ))
94
94
95
- pd .merge_asof (trades , quotes ,
96
- on = 'time' ,
97
- by = 'ticker' ,
98
- tolerance = pd .Timedelta ('10ms' ),
99
- allow_exact_matches = False )
95
+ expected = pd .DataFrame ({
96
+ 'time' : pd .to_datetime (['20160525 13:30:00.023' ,
97
+ '20160525 13:30:00.038' ,
98
+ '20160525 13:30:00.048' ,
99
+ '20160525 13:30:00.048' ,
100
+ '20160525 13:30:00.048' ]),
101
+ 'ticker' : ['MSFT' , 'MSFT' , 'GOOG' , 'GOOG' , 'AAPL' ],
102
+ 'price' : [51.95 , 51.95 ,
103
+ 720.77 , 720.92 , 98.00 ],
104
+ 'quantity' : [75 , 155 ,
105
+ 100 , 100 , 100 ],
106
+ 'bid' : [np .nan , 51.97 , np .nan ,
107
+ np .nan , np .nan ],
108
+ 'ask' : [np .nan , 51.98 , np .nan ,
109
+ np .nan , np .nan ]},
110
+ columns = ['time' , 'ticker' , 'price' , 'quantity' ,
111
+ 'bid' , 'ask' ])
112
+
113
+ result = pd .merge_asof (trades , quotes ,
114
+ on = 'time' ,
115
+ by = 'ticker' ,
116
+ tolerance = pd .Timedelta ('10ms' ),
117
+ allow_exact_matches = False )
118
+ assert_frame_equal (result , expected )
100
119
101
120
def test_examples3 (self ):
102
121
""" doc-string examples """
0 commit comments