I am partial to astropy, eg
from astropy import units as u
density = np.linspace(0, 1, 10)*u.g/u.cm**3
mass = (density*1*u.m**3).to(u.kg)