Bandy hit a two-run homer in the sixth and Thames put Milwaukee ahead with a two-run shot off Carlos Martinez (0-3) in the fifth. Shaw’s three-run blast in the first made it 12 consecutive games going yard for the Brewers, who lead the majors with 32 home runs.
Zach Davies (1-2) allowed four runs on eight hits in 5 1-3 innings. He walked two and struck out five, but needed Thames’ NL-leading eighth home run and seventh in the last eight games for his first win in four starts.
Jacob Barnes pitched the ninth for his first save of the season.
Matt Carpenter hit a solo home run in the top of the fifth and Kolten Wong, whose career-high seven triples led the Cardinals in 2016, hit his first of the season in the top of the second with the bases loaded.
Jedd Gyorko hit a solo home run leading off the Cardinals’ eighth.
Martinez gave up five runs on seven hits in five innings. He walked two and struck out seven.
Cardinals: Infielder Jhonny Peralta was put on the 10-day disabled list because of an upper respiratory condition. He sat out the four previous games, and the move was retroactive to Sunday. He is hitting .120 (3 for 25) with no RBIs in eight games.
Brewers: With right-hander Matt Garza (right groin strain) appearing ready to return from his rehab assignments, manager Craig Counsell must decide how Garza fits into the pitching staff.
St. Louis recalled left-hander Tyler Lyons before Thursday night’s game. His 2016 season ended July 31 because of a right knee stress reaction. He made three appearances in rehabilitation games with Triple-A Memphis this season, allowing two runs in 14 innings.
Cardinals: RHP Adam Wainwright (0-3, 7.24 ERA) makes his fourth start of the season. With a win, he passes Dizzy Dean (134) for sole possession of 6th place all-time in franchise history. He is 14-8 (2.16 ERA) in 28 career starts against the Brewers.
Brewers: RHP Wily Peralta (3-0, 2.65) makes his fourth start of the season and 17th overall against the Cardinals who have been tough on him. He is 0-7 with a 4.85 ERA in his last nine starts against St. Louis.