Nigeria's President Muhammadu Buhari has condemned the killing of 37 people by bandits in the northwestern state of Sokoto, his spokesman said in a statement.