
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Saving and loading files directly into Jupyter notebooks
pip install jupyter-io
jupyter-io provides the in_notebook
function to directly save (i.e. embed) files to Jupyter notebooks.
Suppose you create a Matplotlib figure want to save it as a PDF file.
The following code will save the PDF file to your local environment:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3])
plt.savefig("figure.pdf")
This should work in many cases, however, in a virtual environment like Google Colaboratory, you will not be able to get the file once the Jupyter server is stopped.
By wrapping the file path by in_notebook
, the PDF file will be directly saved to the Jupyter notebook and you will get a download link instead:
import matplotlib.pyplot as plt
from jupyter_io import in_notebook
plt.plot([1, 2, 3])
plt.savefig(in_notebook("figure.pdf"))
The download link works when the Jupyter server is stopped, and even when it does not exist. This makes Jupyter notebooks more portable, for example, to share the output data other than images together with them.
To save a pandas series to a notebook:
import pandas as pd
from jupyter_io import in_notebook
ser = pd.Series([1, 2, 3])
ser.to_csv(in_notebook("series.csv"))
To save a general text to a notebook:
from jupyter_io import in_notebook
with open(in_notebook("output.txt"), "w") as f:
f.write("1, 2, 3\n")
The file loading feature has not been implemented yet.
FAQs
Saving and loading files directly into Jupyter notebooks
We found that jupyter-io demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.