awk group year and month from date in col1 and sum of the group in col2
Try this
$ awk '{a[substr($0,0,7)]+=$2}END{for(b in a){print b,a[b]}}' myfile
2018-02 22
2019-01 213
2018-03 13
2018-04 9
$
For sorted, add sort
$ awk '{a[substr($0,0,7)]+=$2}END{for(b in a){print b,a[b]}}' myfile | sort
2018-02 22
2018-03 13
2018-04 9
2019-01 213
$