Yankee is actually originally a term to describe the Dutch of New Amsterdam (now renamed New York) which, as the common place wants, were supposed to be avid cheese eaters, more or less "Jan Kees", Johnny Cheese, or so I read somewhere. So it's actually a term to describe collectively a foreign community, and the term can have, or not have, a disparaging overtone depending on place, epoch, context, mood and personality. It's probably more the result of an "us and them" attitude that, I think, it's not necessarily disparaging, or does not necessarily originate from a need to be disparaging, although it can easily be used in such a way if both speakers feel the urge of being disparaging.