Skip to content

Instantly share code, notes, and snippets.

@rlabbe
Created March 15, 2018 13:33
Show Gist options
  • Save rlabbe/d574eeac63fd126b2fcd1dc390cc3257 to your computer and use it in GitHub Desktop.
Save rlabbe/d574eeac63fd126b2fcd1dc390cc3257 to your computer and use it in GitHub Desktop.
numpy recarray to dict
def as_dict(rec):
""" turn a numpy recarray record into a dict. this is mostly useful
just to have a human readable output of a record on the console.
as_dict(my_data[234])
"""
return {name:rec[name] for name in rec.dtype.names}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment