How pyforest automated imports work
masterpyforest allows you to use popular Data Science libraries without writing explicit import statements.
How it works:
- You use a library name (e.g.,
pd.read_csv()). - pyforest detects the unused name, imports the library for you, and automatically adds the corresponding import statement (e.g.,
import pandas as pd) to the first cell of your Jupyter notebook. - If a library is never used, it is never imported, keeping your notebook clean and startup times fast.
Key Behaviors:
- Auto-completion: Works as expected. Triggering auto-completion will trigger the lazy import of the module.
- Variable Safety: pyforest uses placeholders and will never mask or overwrite your local variables. If you manually define a variable with the same name as a pyforest placeholder, the placeholder simply becomes unavailable.
- Reproducibility: The import statements are added to your notebook cells, ensuring the notebook remains sharable and reproducible.
# Instead of writing:
# import pandas as pd
# df = pd.read_csv("data.csv")
# You can just write:
df = pd.read_csv("data.csv")