Jeremy Corbyn arrives at a campaign rally in Glasgow in the last days of the campaign. The Labour leader upset many statisticians’ predictions.
Photograph: Murdo Macleod for the Guardian

As the general election results started to trickle in, it fast became clear that things weren’t going as expected. At 1:42am an email pinged into our inboxes from the national news editor. “Blimey O’Reilly – data team, check this out when you can,” it read. The email linked to a tweet which said that Theresa May had lost every marginal constituency that she had visited.

Just a few days earlier, the data team had looked at all the campaign stops the party leaders had made. By comparing the incoming results with that data, by 4am we had an analysis showing that May had indeed lost every marginal she had visited that had declared its result. (Our later analysis with the full results in fact showed there were marginal seats that the Conservatives won.)

The data team doesn’t usually work to such strict deadlines – or in the small hours of the morning – but elections always mean analysing data quickly, and accepting that no data can fully predict what will happen.

In the UK, the data team comprises three journalists, and to the best of our knowledge is the only all-female data team in the world. We come from a variety of backgrounds: Helena Bengtsson worked as a programmer in the early 90s before studying journalism and working for many years with the investigative team at SVT, the Swedish national broadcaster; Caelainn Barr has a background in investigations and has worked at the Wall Street Journal and the Bureau of Investigative Journalism; Pamela Duncan started the datablog at the Irish Times.

The Guardian also has data journalists around the world: in New York, Mona Chalabi is data editor for Guardian US, while Nick Evershed is Guardian Australia’s data and interactives editor.

In London, as we planned our coverage in the weeks leading up to the general election, we worked in close collaboration with the Guardian’s visuals team, which produces graphics and develops interactive digital formats for our journalism. We gathered data from previous votes, all the way back to 1951, and modelled different scenarios. We asked what would happen if all Ukip voters in 2015 defected to the Conservatives. What if all Labour and Liberal Democrat voters decided to vote tactically? Would they be able to win more constituencies, and, if so, which ones? What if the SNP lost 10% of their votes to the Tories? Which constituencies would be affected?

This analysis was shared with the Guardian’s leader writers over the election to inform their editorials, and was the basis for our guide to tactical voting and making your vote count. What we didn’t know was just how much bigger the turnout would be this time, and that young people especially would vote in larger numbers than in 2015.

On the night, as we began to get a clearer view of the election result, we wanted to be able to give readers a sense of the factors that could have affected it. Some of that involved demographic analysis of constituencies, which was planned weeks in advance. To make that data easier for readers to understand, we worked with developers Josh Holder and Niko Kommenda, who create interactive visuals for the web and mobile, to end up with an analysis of where Theresa May’s gamble failed.

Data journalism is about much more than providing numbers for a story. The data team’s job descriptions include the phrase “aggressively collaborative”. In practice, that means that we work together with reporters throughout a story – we’re involved as it develops, rather than delivering a data table or numbers for an article when it’s published. It is not often that we take a statistical table or a report and use that as our only source for a story. Instead, we will spend time gathering data, usually from several different sources, and then structure, clean and analyse it to find the story.

An example is a project on the increase in house prices in the UK. The data team analysed 19m property sales in England and Wales from 1995 to 2014 in collaboration with reporters and developers from the visuals team in the newsroom. The developers created an interactive map on theguardian.com, allowing the reader to see where in the country they could afford to buy a house.

We also wrote an article outlining how house prices had risen much faster than the median income, in which the data was brought to life by human voices. We spoke to a family where, three decades ago, a couple were able to get a mortgage and buy a flat in central London. Thirty years later, their daughter and her partner have found it impossible to do the same thing. The article contains very few numbers – and no numbers from our analysis – but its whole foundation is rooted in our data work.

In other cases, the data that forms the base of the story is not found in published tables or databases. For the Panama Papers revelations, we created our own database from information found in letters written from the Financial Investigations Agency in the British Virgin Islands. The agency was seeking the beneficial owners of offshore companies registered by Mossack Fonseca. By structuring the information in the letters – such as dates, company names and whether or not the owner could be disclosed – and adding that into a spreadsheet, we got an overview of how Mossack Fonseca was repeatedly unable to find out who owned the companies on its books.

Currently, in the UK we are working on the Guardian’s year-long series examining knife crime, Beyond the Blade, which is also informed by a data-lead approach. This reporting project will count the number of children and teenagers who die due to knives during the year. One of the key questions to be answered by the project is the scale of knife crime in the UK, as there are currently no publicly available figures on the number of young people killed by knives. We are gathering data from police forces across the country in a series of freedom of information requests. This information will then be pulled into a publicly available dataset, and will also be used in combination with other data to help determine which areas the team should report on and from.

This collaborative way of working is at the heart of what the data team does. Rather than focus on numbers or statistics, we use data to find the subjects we should be reporting on, where to go to do that, who to talk to, and what questions to ask. Some of the best pieces of data journalism may have no numbers in them at all.