PYTHON SHELF EXTENSION
Python Shelve Extension¶
Extend standard library shelve module. Create a new shelf db that contains a dataframe and a figure.
In [1]:
import pandas as pd
import myshelf
import matplotlib.pyplot as plt
In [2]:
# Dataframe
df = pd.read_csv("https://tessarinseve.pythonanywhere.com/staticweb/dataset_1000.csv",index_col=0)
In [3]:
plt.scatter(df["Col1"].values, df["Col2"].values, alpha=0.2,
c=df["Col5"].values, cmap='viridis')
Out[3]:
In [4]:
from io import BytesIO
In [5]:
png_string = BytesIO()
In [6]:
plt.savefig(png_string,format="png",backend="Agg")
In [7]:
with myshelf.open_default("db_notebook") as nbshelf:
nbshelf["dataframe"] = df
nbshelf["png"] = png_string
In [8]:
myshelf.get_dir()
Out[8]:
Inspect DB¶
In [9]:
db = myshelf.open_default("db_notebook")
In [10]:
db.inspect()
Video¶
In [11]:
from IPython.display import YouTubeVideo
In [12]:
YouTubeVideo("5GCc8xc7Ndg")
Out[12]:
In [ ]: