In [1]:
import json
import pandas as pd
import matplotlib
from matplotlib import pyplot as plt
import seaborn as sns
sns.set()
%matplotlib inline
from bookdbtool.tools import bookDBTool
from bookdbtool.visualizations import running_total_comparison, yearly_comparisons
In [2]:
config_filename = "myconfig.json"
with open(config_filename, "r") as config_file:
c = json.load(config_file)
try:
UN = c["username"].strip()
PWD = c["password"].strip()
DB = c["database"].strip()
DBHOST = c["host"].strip()
bt = bookDBTool(DBHOST, UN, PWD, DB)
except KeyError as e:
print(e)
In [3]:
df1 = bt.get_dataframe(year="2019").sort_values("LastRead")
df1[["Pages"]].describe().style
Out[3]:
In [4]:
plot_size = [16,6]
df1["Progress"] = df1["Pages"].cumsum()
df1.plot("LastRead", "Progress", figsize=plot_size)
Out[4]:
In [5]:
df = bt.get_rank_dataframe()
df.head()
Out[5]:
In [6]:
df[["Pages Read"]].describe().style
Out[6]:
In [7]:
now = df.loc[df.Year == 2020]
print(now)
In [8]:
yearly_comparisons(df, 2020)
In [10]:
running_total_comparison(bt.get_running_year_dataframe(), window=11)
In [ ]: