I HAVE BEEN thinking about who votes for whom and why for a long time. I have been through plenty of campaigns and have sliced and diced numbers for decades. Notwithstanding the availability of far more information than we could have ever imagined decades ago, there is still no one simple answer as to who votes for whom.

How people vote is significantly informed by the communities and networks to which they belong. Those “communities,” however, are far more diverse than their ethnic, racial, or geographic features. We do a great disservice to the power of individual thinking to presume that any group is monolithic.

The factors leading a person to vote for a candidate are many: friends and neighbors, ideology, ethnicity/race, and gender. In the Boston mayor’s race, gender is, of course, not an issue, with voters choosing between two women candidates, one of whom will make history as the city’s first female leader. In addition to Boston’s having its first female mayor, the next mayor will be the first to identify as a person of color, as did all five major candidates in the preliminary.

Friends and neighbors are a very important factor. It determined in many cases who did well where in the September preliminary election. No one should be surprised that John Barros did well in the Uphams Corner neighborhood of Dorchester near his home or that Andrea Campbell, a district city councilor representing Mattapan and parts of Dorchester, did well on Ashmont Hill. Or that Michelle Wu, the daughter of Taiwanese immigrants, did well in Chinatown, or Anissa Essaibi George up and down the coast in Dorchester where she grew up, or that Kim Janey won more than 50 percent of the vote in Ward 12, the core of the Black community, where she and her family have lived for decades. Friends and neighbors count.

Ideology also counts. Without any doubt, neighborhoods that identify as progressive, such as Jamaica Plain, voted in great numbers for Wu, with Campbell also registering well in many of its precincts.

On the other hand, neighborhoods full of public employees, who are by nature averse to change, including public safety personnel who shudder at the “defund the police” movement, voted heavily for Essaibi George. These are not surprising distinctions.

Ethnicity/race is probably more complicated than it used to be. When I was on the City Council, there were very few Hispanics voting in Boston and most of those who identified as Black were African American. Life has changed plenty in the last few decades. The Hispanic community, significantly ignored in many analyses, is today growing and diverse. There are so many Salvadorans now living in East Boston that the Boston office of the Salvadoran consulate is located there. The Hispanic community is not monolithic any more than the Italians were when I was running for office.

The city’s Black community, too, is not monolithic. It includes African Americans in great numbers as well as large communities of Haitians and people from other Caribbean islands. There are also Black residents from Africa in great numbers: Ugandans, Nigerians, and those from other countries. Many have now been here for a long time and are citizens and regular voters. Each of these groups has a different identity and different thinking towards politics. The Black community is no more monolithic than the Irish, of whom Al Smith, the New York governor and 1928 Democratic presidential nominee, said 100 or so years ago, “The only time the Irish stand together is at the reading of the Gospel.”

There are many occasions, notwithstanding whatever some sociologists and political scientists may think, where Black people vote for white candidates in great numbers and white people vote for Black candidates.

Byron Rushing, a Black politician who served in the Legislature for over 30 years, represented a district primarily consisting of the South End and Lower Roxbury. As the years progressed and gentrification took hold, his district became less and less Black and more white. Yet, he was reelected even when competing against very legitimate white candidates. Former House Speaker Tommy Finneran, a classic Irish Catholic politician, represented a Dorchester/Mattapan district that was majority Black. Yet, even when he had legitimate Black opponents, he prevailed by large margins, even in his opponents’ home precincts.

Notwithstanding other voting trends, elected officials who do a good job and deliver for their constituents secure support, often without regard to race or ethnicity. These are factors that may not be easily identified from the Census but are indicative of our ever-changing America.