In [195]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
import sqlite3
import matplotlib # ; matplotlib.use('nbagg')
# Handle date time conversions between pandas and matplotlib
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
# Use white grid plot background from seaborn
sns.set(font_scale=1.5, style="whitegrid")
if 0:
df1 = pd.read_csv('projects.csv')
printt(df1)
In [196]:
%matplotlib inline
In [197]:
conn = sqlite3.connect("./projects.db")
cur = conn.cursor()
cur.execute('select count(*) from projects'); print(cur.fetchall())
In [ ]:
In [198]:
cur.execute('select * from projects order by num_dirs desc limit 1'); print(cur.fetchall())
In [199]:
# how many releases were made this year
In [200]:
df = pd.read_sql_query('select * from projects order by date desc limit 1', conn); df.head()
Out[200]:
In [ ]:
In [201]:
cur.execute('select count(*) from projects where date > "2020"'); print(cur.fetchall())
In [ ]:
In [202]:
cur.execute('select distinct(project) from projects where date > "2020"'); print(cur.fetchall())
In [ ]:
In [203]:
# NP plot demo
if 0:
# Prepare the data
x = np.linspace(0, 10, 100)
plt.figure(figsize=(10,10))
# Plot the data
plt.plot(x, x, label='linear')
# Add a legend
plt.legend()
# Show the plot
plt.show()
In [204]:
df.index.values
Out[204]:
In [ ]:
In [227]:
query = """select
date(date, 'start of year') as year,
count(*) as c
from projects
where date >= '2000-01-01'
group by 1
"""
df = pd.read_sql_query(query, conn)
if 0:
df.head()
elif 0:
fix, ax = plt.subplots(figsize=(12,12))
ax.bar(df.index.values, df.c)
plt.show()
In [274]:
# df = pd.read_sql_query("select count(*) from projects where project='bash'", conn); df.head()
query = """
SELECT
strftime('%m', date(date, 'start of month')) as month,
count(*) as c
FROM projects
WHERE project = 'bash'
GROUP BY month
"""
df = pd.read_sql_query(query, conn)
if 1:
# print(df.head())
print(df)
if 1:
fix, ax = plt.subplots(figsize=(12,12))
ax.bar(df.month, df.c)
plt.show()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [256]:
_
Out[256]:
In [ ]: