The woman was seriously injured in the early morning crash and was flown to a Stockholm hospital, police spokesman Lars Bystrom said. No one else was injured.
Bystrom said the woman was arrested on suspicion of endangering the public.
Tomas Hedenius, a spokesman for train operator Arriva, said the woman, born in 1990, stole the four-car train at a depot outside Stockholm.
She then drove it about a mile (1.6 kilometers) to the end station on the railway line, where it jumped off the tracks, careered for about 30 yards (25 meters) and crashed into a three-story building.
Photographs from the scene showed the crumpled front car of the train buried deep into the structure.
“There were three families inside the apartment building, but no one was injured. At least not physically,” Hedenius said.
The motives of the woman, who worked for a company contracted to carry out cleaning for the train operator, were not immediately clear.
“We have only heard good things about her. We’re investigating how this could happen, and why she did what she did,” Hedenius said.