Skip to content

Instantly share code, notes, and snippets.

@ricgu8086
Created July 6, 2022 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricgu8086/653e810f4aca1da3d09e0c3036c9383f to your computer and use it in GitHub Desktop.
Save ricgu8086/653e810f4aca1da3d09e0c3036c9383f to your computer and use it in GitHub Desktop.
# From https://stackoverflow.com/questions/23586510/return-multiple-columns-from-pandas-apply
def sizes(s):
return locale.format("%.1f", s / 1024.0, grouping=True) + ' KB', \
locale.format("%.1f", s / 1024.0 ** 2, grouping=True) + ' MB', \
locale.format("%.1f", s / 1024.0 ** 3, grouping=True) + ' GB'
df_test['size_kb'], df_test['size_mb'], df_test['size_gb'] = zip(*df_test['size'].apply(sizes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment