pandas human readable numbers
def human_readable_format(value, pos=None): ''' Convert number in dataframe to human readable format `pos` argument is to used with the matplotlib ticker formatter. ''' assign_unit = 0 units = ['', 'K', 'M', 'B'] while value >= 1_000: value /= 1_000 assign_unit += 1 return f"{value:.2f} {units[assign_unit]}"
Are there any code examples left?
New code examples in category Other