score:15

Accepted answer

to sum your inner dictionary just do:

dictsum = pt.select(x => x.unitssoldbyyear.values.sum()).sum()

or equally:

dictsum = pt.sum(x => x.unitssoldbyyear.values.sum())

edit:

according to the op comment, this creates a dictionary with the sum by each key:

dictsum = pt.selectmany(kvp => kvp.unitssoldbyyear)
            .groupby(kvp => kvp.key)
            .todictionary(grp => grp.key,grp => grp.sum(kvp => kvp.value))

Related Query

More Query from same tag