Extend data frame with missing dates by group and interpolate
<p>I have a data frame like this:</p>

<pre><code>df = pd.DataFrame({"ID":["A", "A", "A" ,"B", "B"], "date":["06/24/2014","06/26/2014","06/29/2014","07/02/1999","07/04/1999"], "value": ["4","6","9","2","4"] })


ID        date value
0  A  06/24/2014     4
1  A  06/26/2014     6
2  A  06/29/2014     9
3  B  07/02/1999     2
4  B  07/04/1999     4
</code></pre>

<p>For each group, I want to extend the data frame to include all the missing dates between the max and the min of the dates, and then interpolate the column value linearly. The result should look like this:</p>

<pre><code> ID        date value
0  A  06/24/2014     4
1  A  06/25/2014     5
2  A  06/26/2014     6
3  A  06/27/2014     7
4  A  06/28/2014     8
5  A  06/29/2014     9
6  B  07/02/1999     2
7  B  07/03/1999     3
8  B  07/04/1999     4
</code></pre>

<p>My idea so far is as follows:</p>

<p>Set date as the index:</p>

<pre><code>df.date = pd.DatetimeIndex(df.date)
</code></pre>

<p>Group by ID and apply the following function:</p>

<pre><code>B = df1.groupby('ID').apply(lambda x: x.reindex(pd.date_range(x.date.min(),x.date.max()), fill_value=0) )
</code></pre>

<p>What would be the best approach for this?</p>

<p>thank you,</p>