We study the Bose-Einstein condensates of trapped Bose gases in the Gross-Pitaevskii regime. We show that the ground state energy and ground states of the many-body quantum system are correctly described by the Gross-Pitaevskii equation in the large particle number limit, and provide the optimal convergence rate. Our work extends the previous results of Lieb, Seiringer and Yngvason on the leading order convergence, and of Boccato, Brennecke, Cenatiempo and Schlein on the homogeneous gas. Our method relies on the idea of 'completing the square', inspired by recent works of Brietzke, Fournais and Solovej on the Lee-Huang-Yang formula, and a general estimate for Bogoliubov quadratic Hamiltonians on Fock space.