Out of 510 U.S. cities studied, a company called Apartment List ranks Vallejo the 507th best for families. Only three cities — Pueblo, Colo., Jackson, Miss., and Ft. Lauderdale, Fla. — fared worse. Oakland was only slightly better, ranking 503.

On the flip side, Pleasanton ranked No. 18 across the country and was the highest-ranking city in the Bay Area.

The reason for the study is to help families with children find the best place to live based on safety, housing affordability, education quality and child friendliness, company officials said.

Vallejo earned low scores on every measure.

Safety, which used FBI data to track the number of violent and property crimes per 100,000 residents, accounts for 35 percent of the ranking. To figure housing affordability, which accounts for 30 percent, they used Census data on median gross rent as a percentage of household income. Twenty-five percent of the ranking is based on education quality, which analysts determined using high school graduation rates as collected by the Department of Education. Child friendliness accounts for 10 percent of the ranking, and is figured using Census data on the percentage of the population under age 18.

Vallejo got a safety score of 21.5, a housing affordability score of 3.8 and an education score of 14.9 It got a child friendliness score of 14.7, for an overall score of 13.9 and an F rating. Oakland also received an overall score of F, with a safety score of only 1.8 and an affordability score of 37.6.

By comparison, Pleasanton had a safety score of 80.6, a housing affordability score of 87.5, an education score of 97 and a child-friendliness score of 88.23. It had an overall score of an A.

Reading this on your phone or tablet? Stay up to date on East Bay news with our new, free mobile app. Get it from the Apple app store or the Google Play store.

Other East Bay cities in the top 50 were Fremont at No. 33 and San Ramon at No. 41.

The No. 1 spot in the study went to Flower Mound, Texas, which earned safety and affordability scores of more than 99 and an education of score of about 92. Its child friendliness score was nearly 95 for an overall score of more than 97 and an A+ grade.

Apartment List’s Andrew Woo explained Vallejo’s poor showing in the housing affordability category, for instance, saying it doesn’t measure how much housing costs, but, rather the percentage of what people earn that they have to spend on housing.

“The metric that we used to measure affordability is median gross rent as a percentage of household income. Rather than simply measuring housing costs, this figure looks at how housing costs align with earnings potential in a given community,” Woo said. “In Vallejo, the median renter spends 39.8 percent of household income on rent, whereas in Napa this figure is 31.4 percent; this metric isn’t saying that rents are less expensive in Napa than Vallejo, just that renters in Napa are in a better financial position to afford the costs.”

Woo went on to say that according to the Apartment List study, Vallejo could be described as a place where one pays exorbitant rents to live in a crime-infested neighborhood with lousy schools.

That description, “seems to align pretty well with our findings,” he said. “Vallejo received an overall grade of F and ranked No. 507 out of 510 cities that we looked at; as for the individual components, Vallejo received a D for safety and F’s for affordability, education quality, and child-friendliness.”

The complete rankings can be found at www.apartmentlist.com/rentonomics/2017-best-cities-for-families

Contact Rachel Raskin-Zrihen at (707) 553-6824.