title: Convert A dataframe to a dictionary with custom structure
body: <p><strong>I have the following data frame:</strong></p>
  
  <pre><code>             3        10          6          4           timestamp
  462  75.768780  21.47490  20.725380  100.00000 2020-04-08 08:30:05
  463  77.612500  21.47490  21.025310  100.00000 2020-04-08 08:30:35
  464  77.612500  18.41914  21.025310  100.00000 2020-04-08 08:30:40
  465  75.851290  18.41914  19.776660  100.00000 2020-04-08 08:31:05
  466   2.908084  16.36317   4.460456    4.48286 2020-04-08 08:31:25
  </code></pre>
  
  <p><strong>I want to convert this into a format like below if the df contains a time stamp column:</strong></p>
  
  <pre><code>{datetime.datetime(2020, 4, 8, 8, 30, 5, tzinfo=&lt;UTC&gt;): {'3': 75.76878,
    '10': 21.474900000000005,
    '6': 20.72538,
    '4': 100.0},
   datetime.datetime(2020, 4, 8, 8, 30, 35, tzinfo=&lt;UTC&gt;): {'3': 77.6125,
    '10': 21.474900000000005,
    '6': 21.02531,
    '4': 100.0},
  }
  </code></pre>
  
  <p><strong>If the data frame is in the format without timestamp column:</strong></p>
  
  <pre><code>       1       2                  3
  36026  7.2246  5.4106             0.0
  36027  7.2154  5.4115             0.0
  36028  7.1923  5.4111             0.0
  36029  7.2028  5.4106             0.0
  36030  7.2141  5.4123             0.0
  </code></pre>
  
  <p><strong>I want to convert this data frame into a format like below:</strong></p>
  
  <pre><code>{36026: {'1': 7.2246, '2': 5.4106, '3': 0.0},
   36027: {'1': 7.2154, '2': 5.4115, '3': 0.0},
   36028: {'1': 7.1923, '2': 5.4111, '3': 0.0},
   36029: {'1': 7.2028, '2': 5.4106, '3': 0.0},
   36030: {'1': 7.2141, '2': 5.4123, '3': 0.0}}
  </code></pre>
  
  <p>Currently what I am trying to achieve this using <code>df.iterrows()</code> in a for loop and then converting it to the corresponding format. </p>
  
  <p>Any Efficient solution would be great.</p>
  
  <p>Thanks in advance.</p>