Resampling OHLC tick data and filling gaps in Pandas

Viewed 4847

I have some tick data in this form:

date                 price    amount
2011-09-13 13:53:36  5.80     1.0000
2011-09-13 13:53:44  5.83     3.0000
2011-09-13 14:32:53  5.90     2.0000

And I've resampled the price with:

resampledData.price.resample('55min', how="ohlc")

Now I need to fill out the missing data and the only way I came up with was:

closes = resampledData.close
closes = closes.fillna(method='pad')
resampledData = resampledData.open.fillna(closes)
resampledData = resampledData.high.fillna(closes)
resampledData = resampledData.lowe.fillna(closes)
resampledData = resampledData.close.fillna(closes)

But this looks really bad, is there a more efficient way to do it?

Also, is there a way to ressample two columns at the same time? Like the price with "ohlc" and the amount with a method "sum"?

1 Answers
Related