title: Group by the data based on the two column (id and date) and then build the rows with the values in data frame
body: <p>I have a data frame with multiple id in column id. For each day, I have 5 time steps. (6:00, 6:15, 6:30, 6:45, 7:00) However, some days does not have 5. And I want to fill the missing value as Nan.. Let see the following example,</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame()
  df['id'] =   [1, 1, 1, 1, 1, 2, 2, 2,3, 3, 1, 1]
  df['val'] = [11, 10, 12, 3, 4, 5, 125, 45,31, -2,5,6]
  df['date'] = ['2019-03-31 06:00:00','2019-03-31 06:15:00', '2019-03-31 06:30:00', '2019-03-31 06:45:00', '2019-03-31 07:00:00', '2019-03-31 06:00:00', '2019-03-31 06:30:00',
                '2019-03-31 06:45:00', '2019-03-31 06:00:00', '2019-03-31 06:15:00', '2019-04-1 06:00:00', '2019-04-1 06:15:00']
  </code></pre>
  <p>For example, for <strong>id=1</strong> we have 5 time steps at time 2019-03-31 and two value for the 2019-04-01.</p>
  <p>For <strong>id=2</strong>, we have 3 time steps.</p>
  <p>for <strong>id=3</strong>, we have 2 time steps.</p>
  <p>So,</p>
  <p><strong>I want to sticks values in one rows and add only the day of the time to that row.</strong>
  My final df is as follow:</p>
  <p><a href="https://i.stack.imgur.com/7fYlv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7fYlv.png" alt="enter image description here" /></a></p>
  <p>Now, I am using the following code which stick all the values to each other and create 7 columns. But I want 5 columns.</p>
  <pre><code>df[&quot;dates&quot;] = pd.to_datetime(df[&quot;date&quot;]).dt.date
  new_df = df.pivot(index=[&quot;id&quot;, &quot;dates&quot;], columns=&quot;date&quot;, values=&quot;val&quot;)
  new_df.columns = [f&quot;val{i+1}&quot; for i in range(new_df.shape[1])]
  new_df.reset_index() 
  </code></pre>
  <p>Can you help me with that?</p>