Extreme heat can take a toll on mental health - and young people and women are among the groups most at risk, according to one study.