We introduce a novel two-step approach for estimating a probability density function (pdf) given its samples, with the second and important step coming from a geometric formulation. The procedure involves obtaining an initial estimate of the pdf and then transforming it via a warping function to reach the final estimate. The initial estimate is intended to be computationally fast, albeit suboptimal, but its warping creates a larger, flexible class of density functions, resulting in substantially improved estimation. The search for optimal warping is accomplished by mapping diffeomorphic functions to the tangent space of a Hilbert sphere, a vector space whose elements can be expressed using an orthogonal basis. Using a truncated basis expansion, we estimate the optimal warping under a (penalized) likelihood criterion and, thus, the optimal density estimate. This framework is introduced for univariate, unconditional pdf estimation and then extended to conditional pdf estimation. The approach avoids many of the computational pitfalls associated with classical conditional-density estimation methods, without losing on estimation performance. We derive asymptotic convergence rates of the density estimator and demonstrate this approach using both synthetic datasets and real data, the latter relating to the association of a toxic metabolite on preterm birth.