Save and load vars, functions ...
Project description
Save and load vars, functions, objects ...
How to save the global vars (or any other variable)
# Create a file
import pandas as pd
from save_load_vars import save_vars_pkl
df = pd.read_csv(
"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"
)
def myfunction(x):
return str(x) + "bbbb"
myfunction2 = lambda k: myfunction(k)
partofframe = df.Name.copy()[:50]
# Save the global vars
save_vars_pkl(g=globals(), folder=f"f:\\pklsavetest", interface="dill", protocol=None)
How to load the saved data
from save_load_vars import load_vars_pkl
load_vars_pkl(folder=f'f:\\pklsavetest',
name=__name__,interface='dill')
print(df)
print(myfunction(44))
print(partofframe)
print(df.Cabin.apply(myfunction2))
How to create global variables from a dict
from save_load_vars import globals_from_dict
didi={
'a':'bobo',
'b':'bobao',
'c': [4,3,3]
}
globals_from_dict(didi,__name__)
print(a)
print(b)
print(c)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
save_load_vars-0.11.tar.gz
(4.3 kB
view details)
Built Distribution
File details
Details for the file save_load_vars-0.11.tar.gz
.
File metadata
- Download URL: save_load_vars-0.11.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcfb8dae2c660dd080c054727e694e81e2773bb76ae8492a78991ccb8464afe4 |
|
MD5 | 979d0816c91a1190108ac6d156260265 |
|
BLAKE2b-256 | 6d1209254651dc0a963ba6cc0bd34e9141e78bef4b60d52486f0ec2e592432d0 |
File details
Details for the file save_load_vars-0.11-py3-none-any.whl
.
File metadata
- Download URL: save_load_vars-0.11-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ce80d5fd3ef27d0161c7d5abc74317da80d9efdede690ad04a5a3f3878a2115 |
|
MD5 | a8c70ddff6fd97d018d1a20e21290029 |
|
BLAKE2b-256 | e33dc1bfc110128cc45cc4118a969de631ab7d3006347672f16964bfb8c6c75a |