Elegantly avoid columns containing NaNs?
You can use d2[:, dnan] to select the wanted columns. (I'm assuming you want to process all rows unlike your current code)

def dosomething(d2):
    dnan = ~numpy.isnan(d2.sum(axis=0))
    validcols = d2[:, dnan]
    normalized = numpy.transpose((d2.T - numpy.mean(validcols, axis=1)) / numpy.std(validcols, axis=1))
    l = nanmean(normalized, axis=0)
    return l