This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock

Thursday, May 18, 2017

Save a python variable using Numpy

This just might revolutionize the way I return to projects and test functions

You can save a python variable using numpy!!!

Sure wish I would have known this a long time ago. For example, if you have a large python dictionary, you can save the dictionary, and then load it and use it later.

Example:

SomeDictionary = {'Name': np.array([1,2,3,4,5]), 'DATES':np.array([1,2,3,4,5])}

np.save('PyDict.npy', SomeDictionary)

get_the_dict = np.load('PyDict.npy').item()

What a miracle :)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.