title: Using d3.nest to sum values according to a specific key and filtered by another key
body: <p>I have a csv file which contains three columns : </p>
  
  <pre><code>College,Undergraduate,IOP
  Science,1,Yes
  Science,3,No
  Arts,2,Yes
  Arts,1,No
  Science,2,Yes
  </code></pre>
  
  <p>I want to create a variable : <code>[{type: "Arts", Applied: 2},{type:"Science",Applied:3}]</code>. I want to sum only the IOP wish values are Yes</p>
  
  <p>My code:</p>
  
  <pre><code>         function csvToJSONUSPstudents(csv){
  
                  d3.csv(csv, function(error, csv_data) {
                  if (error) throw error;
  
  
                  var datas = d3.nest()
                    .key(function(d) { return d.College;})
                    .rollup(function(d) {
  
  
                    return {
  
                       Applied: d3.sum(d, function (g) {
                         return g.Applied;
                       }),
  
                     };
  
                       }).entries(csv_data);
  
  
                    var data = [];
                    var x = {};
  
                    for (var i = 0 ; i&lt; datas.length;i++){
  
                        x =  {type:datas[i].key , 
                        Applied:datas[i].values.Applied}
                        data.push(x)
                         }
  
                        console.log(data);
  
  
                    });
  
  
  
  
  
  
  
                    }
  </code></pre>