title: Reading a csv file into a multidimensional array
body: <p>I have read answers similar to this questions, but do not find such as solution to my goal. I have a large <code>csv</code> file of nearly 150MB, having the following form:</p>
  
  <pre><code>logs.csv:
  
  id,lat,lon,days,mode
  656001,41.163172,-8.5838214,42461.0046296296,3
  656001,41.163237,-8.58381,42461.0046412037,3
  656001,41.1632328,-8.5838378,42461.0046527778,3
  656001,41.163234,-8.5838637,42461.0046643519,3
  656001,41.1632204,-8.583885,42461.0046759259,3
  .....
  758001,39.9966599,-8.6113725,42461.4125578704,1
  758001,39.9969224,-8.6111087,42461.4125694444,1
  758001,39.9972031,-8.6108471,42461.4125810185,1
  ....
  829000,40.6022533,-7.2600605,42461.6981944444,2
  829000,40.6020222,-7.2601668,42461.6982060185,2
  829000,40.6017725,-7.2602641,42461.6982175926,2
  829000,40.6015003,-7.2603968,42461.6982291667,2
  ......
  863025,41.1459056,-8.6131507,42461.7629050926,0
  863025,41.1459103,-8.6131553,42461.7629166667,0
  863025,41.1459149,-8.6131682,42461.7629282407,0
  </code></pre>
  
  <p>Then I want to load this data as array of arrays, by <code>id</code> such that each of the nested array has the four columns: <code>lat, lon, days, mode</code> in the following form:</p>
  
  <pre><code>[
    [41.163172 -8.5838214 42461.0046296296 3]
    [41.163237 -8.58381 42461.0046412037 3]
    [41.1632328 -8.5838378 42461.0046527778 3]
    ...
    [39.9966599 -8.6113725 42461.4125578704 1]
    [39.9969224 -8.6111087 42461.4125694444 1]
    .....
    .....
    [41.1459056 -8.6131507 42461.7629050926 0]
    [41.1459103 -8.6131553 42461.7629166667 0]
    [41.1459149 -8.6131682 42461.7629282407 0]
  ]
  </code></pre>
  
  <p>I first loaded this data as a <code>numpy ndarray</code>, like so:</p>
  
  <pre><code>my_data = np.genfromtxt('logs.csv', delimiter=',', skip_header=True)
  my_data.shape
  (22, 5)
  </code></pre>
  
  <p>Then trying to work it further to the desired output (by <code>id</code>) however this alters the shape of the intended array:</p>
  
  <pre><code>#group by id
  unique_id = set(my_data[:,0])
  unique_id
  {656001.0, 758001.0, 829000.0, 863025.0}
  
  grouped_data = np.array([my_data[my_data[:,0]== pvalue, 1:]
                         for pvalue in unique_id])
  grouped_data.shape
  (503,)
  </code></pre>
  
  <p>But I want have the shape of the nested array as I would iterate over its elements. I was expecting something of shape <code>(X,4)</code></p>
  
  <p>I then try using <code>pandas dataframe</code>, so:</p>
  
  <pre><code>data = pd.read_csv('logs.csv')
  data.head()
        id       lat         lon        days       mode
  0   656001  41.163172   -8.583821   42461.004630    3
  1   656001  41.163237   -8.583810   42461.004641    3
  2   656001  41.163233   -8.583838   42461.004653    3
  3   656001  41.163234   -8.583864   42461.004664    3
  4   656001  41.163220   -8.583885   42461.004676    3
  </code></pre>
  
  <p>Apparently, pandas wouldn't yield the intended result:</p>
  
  <pre><code>data.groupby('id').head()
        id       lat        lon        days        mode
  0   656001  41.163172   -8.583821   42461.004630    3
  1   656001  41.163237   -8.583810   42461.004641    3
  2   656001  41.163233   -8.583838   42461.004653    3
  3   656001  41.163234   -8.583864   42461.004664    3
  .....
  </code></pre>
  
  <p>None of my attempts could result in the required array of arrays as shown in the beginning. How do I please do this?</p>