We present a method for consistent nonparametric estimation of a demand function with nonseparable unobserved taste heterogeneity subject to the shape restriction implied by the Slutsky inequality. We use the method to estimate gasoline demand in the United States. The results reveal differences in behavior between heavy and moderate gasoline users. They also reveal variation in the responsiveness of demand to plausible changes in prices across the income distribution. We extend our estimation method to permit endogeneity of prices. The empirical results illustrate the improvements in finite-sample performance of a nonparametric estimator from imposing shape restrictions based on economic theory.