Thread: Interpolating Values

Interpolating Values

From
James David Smith
Date:
Hi everyone,

Some ideas about how to go about something would be appreciated
please. I have data that looks like this:

person_id      |               date_time                          |
  person_black_carbon
-----------------------------------------------------------------------------------------------------
       1             |        2012-07-12 10:48:00               |
             34
       1             |        2012-07-12 10:49:00               |
             567
       1             |        2012-07-12 10:50:00               |
             0
       1             |        2012-07-12 10:51:00               |
             98

       2             |        2012-07-12 10:48:00               |
             34
       2             |        2012-07-12 10:49:00               |
             0
       2             |        2012-07-12 10:50:00               |
             32
       2             |        2012-07-12 10:51:00               |
             98

       3             |        2012-07-12 10:48:00               |
             0
       3             |        2012-07-12 10:49:00               |
             567
       3             |        2012-07-12 10:50:00               |
             0
       3             |        2012-07-12 10:51:00               |
             98

You will see that for each person I have black carbon readings for
each minute. However what I actually need is a reading for each
second. What I have missed out of the table above is that inbetween
each of the minutes shown, there are an addition 59 rows which have
the correct time in date_time, but a blank person_black_carbon figure.
What I want to do is to fill in the person_black_carbon figure by
interpolating from the figure above/below it.

I hope that makes sense. Thanks for any help.

James