def getstdev(l, mean): """ Get the mean of the values in the list, or NaN if there is none. """ if len(l) > 0: return statistics.pstdev(l, mean) else: return float('nan')