I have a CSV of fan fictions published over a time period. It looks something like:
id,published_date,characters
1,2017-01-01,'['Joe','Bob','Mary']'
2,2017-01-02,'['Mary']'
3,2017-01-02,'['Bob','Mary']'
I had pretty good success writing a key function by published_date, but now I want to see if I can write a key function for characters. So for the first row, Joe, Bob, and Mary would all be keys that have the value 2017-01-01, then in the second row 2017-01-02 would be added to Mary's key. At the end I would like to do a rollup on published_date in order to get a count of number of fan fictions published about Mary on each date. I think the end data would look something like this:
{
Bob: {2017-01-01: 1}, {2017-01-02: 1},
Joe: {2017-01-01: 1},
Mary: {2017-01-01: 1}, {2017-01-02: 2}
}
So for published_date, my code looked like:
var dates = d3.nest()
.key(function(d) { return parseDate(d.published_date); })
.rollup(function(v) { return v.length; })
.entries(csv_data);
And if my characters column were not a list, then I believe this would work:
var dates = d3.nest()
.key(function(d) { return d.characters; }) // key by character
.key(function(d) { return parseDate(d.published_date); })
.rollup(function(v) { return v.length; })
.entries(csv_data);
Is there a way I can change key(function(d) { return d.characters; }) to actually create multiple keys?
Thanks!