Ramirez was an American League All-Star in 2014, and Silver Slugger Award winner at shortstop in 2010 and '14.
The Rays acquired Duffy at the non-waiver Trade Deadline, sending starter Matt Moore to San Francisco in return. Duffy was on the disabled list with a strained Achilles at the time of the deal. He hit .276/.300/.355 with one home run and seven RBIs in 21 games with Tampa Bay.
Duffy, the National League Rookie of the Year Award runnerup in 2015, hit a combined .258/.310/.357 with five home runs and 28 RBIs in his sophomore season.