On Wednesday, Pandora became the latest Silicon Valley company to publicize a breakdown of its employees by gender and race. Notably, Pandora employs a much larger share of female workers—about forty-nine per cent globally—than most of the other big companies that recently disclosed their numbers, including Google, Apple, Twitter, and Facebook (in all these companies, women only make up around thirty per cent of employees). Pandora also appears to have a larger share of underrepresented minorities than many of the others. The company, commentators concluded from the figures, must be doing something right.

It’s notable that these disclosures no longer come as much of a surprise; not long ago, this kind of information tended to be hidden away in human-resources departments. (Companies of a certain size must report diversity figures to the government, but they don’t have to make them public.) That changed in May, when Laszlo Bock, Google’s senior vice-president of people operations, published a blog post that began, “We’ve always been reluctant to publish numbers about the diversity of our workforce at Google. We now realize we were wrong, and that it’s time to be candid about the issues.”

The figures were startling. As of January, Google’s global workforce was seventy per cent male and thirty per cent female. Sixty-one per cent of workers in the U.S. were white. “Google is miles from where we want to be,” Bock admitted. So, apparently, is much of the rest of Silicon Valley. Google’s disclosure inspired, or perhaps shamed, LinkedIn, Yahoo, Facebook, Twitter, and eBay into following suit, and their numbers don’t look much better.

Observers have noted, though, that there are variations in the statistics. Pandora and eBay, in that order, have shares of female employees that come closer to an even split.

Apple, followed by Pandora, has the biggest share of Hispanic employees, while Apple and eBay have the highest proportion of workers who are black. (Gigaom has a nice breakdown of the numbers.) Some of the coverage of these differences has tended to congratulate companies like Pandora, whose figures look relatively diverse. But to suggest that these firms are doing something right, and that the less diverse ones are doing something wrong, is an oversimplification. I spoke to Hadi Partovi, a veteran entrepreneur and investor in Silicon Valley, who said that the discrepancies seem to stem from the nature of the companies’ employee bases. Across all the companies, tech workers, like software engineers, tend to be disproportionately male, and either white or Asian. At Pandora, for example, eighty-two per cent of global tech workers are male, while eighteen per cent are female—and white or Asian workers make up eighty-eight per cent of its U.S. tech workers. What makes certain companies look much more diverse than others may be that they happen to have fewer tech employees compared with workers in other areas, like marketers or salespeople.

What’s more, from Partovi’s perspective, the astonishing maleness and whiteness of Silicon Valley’s tech workers has less to do with Silicon Valley itself than with the education system that prepares kids to work there—or, more often, doesn’t do so. Women earn about eighteen per cent of computer-science degrees in the U.S. Black and Hispanic students each earn ten per cent or fewer. “If you have a really undiverse student population, it’s hard to make an even more diverse workforce,” Partovi said.

Partovi has co-founded a nonprofit, Code.org, that tries to expand participation in computer science by women and underrepresented people of color. But instead of targeting Silicon Valley companies, or even universities, the organization is focussing on elementary schools, where Partovi believes the problem starts. Most schools don’t teach computer science, and those that do tend to be suburban or private schools that serve children from privileged—and, often, white or Asian—families. What’s worse, those that do teach computer science tend to be high schools, and once kids get to high school they already have preconceived notions about what a computer programmer looks like, which can dissuade students, including girls, who don’t fit that image.

So Code.org is persuading elementary-school teachers to include computer-science classes in their curriculum—for all students, not just the ones who opt in. “If you tell a nineteen-year-old black girl, ‘Do you want to take a computer-science class?,’ they don’t think it’s fun, because society has told them that computer programmers are white males,” he said. “The earlier we start, they have no stereotypes.”

After talking with Partovi, I called Nicki Washington, a black woman who is a professor of computer science at Howard University, a historically black institution, and who has been programming since her childhood in Durham, North Carolina. By way of introduction, she told me, “I would say that my background probably isn’t the norm.” Her mother was a software programmer at I.B.M., and Washington grew up surrounded by black female engineers: “They were my mother’s friends and co-workers.”