Bump data.
This commit is contained in:
parent
8f8cd06beb
commit
122e49781c
Binary file not shown.
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 82 KiB |
Binary file not shown.
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 68 KiB |
|
@ -14,6 +14,7 @@ from pypinfo.core import build_query, create_client, create_config, parse_query_
|
||||||
from pypinfo.db import get_credentials
|
from pypinfo.db import get_credentials
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib.dates import date2num
|
from matplotlib.dates import date2num
|
||||||
|
import matplotlib.ticker as mtick
|
||||||
from scipy.interpolate import make_interp_spline
|
from scipy.interpolate import make_interp_spline
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
@ -116,11 +117,12 @@ def plot_main():
|
||||||
versions = db.fetch_python_version()
|
versions = db.fetch_python_version()
|
||||||
biggest_value = max(version["download_count"] for version in versions)
|
biggest_value = max(version["download_count"] for version in versions)
|
||||||
for row in versions:
|
for row in versions:
|
||||||
if row["download_count"] > biggest_value / 20:
|
if row["download_count"] <= biggest_value / 20:
|
||||||
by_version[row["python_version"]][0].append(
|
continue
|
||||||
mean_date(row["start_date"], row["end_date"])
|
mid_of_month = mean_date(row["start_date"], row["end_date"])
|
||||||
)
|
_, number_of_days = calendar.monthrange(mid_of_month.year, mid_of_month.month)
|
||||||
by_version[row["python_version"]][1].append(row["download_count"])
|
by_version[row["python_version"]][0].append(mid_of_month)
|
||||||
|
by_version[row["python_version"]][1].append(row["download_count"] / number_of_days)
|
||||||
plt.style.use("tableau-colorblind10")
|
plt.style.use("tableau-colorblind10")
|
||||||
plt.figure(figsize=(10, 10 * 2 / 3))
|
plt.figure(figsize=(10, 10 * 2 / 3))
|
||||||
fmt = iter(cycle(["-", "--", ":", "-."]))
|
fmt = iter(cycle(["-", "--", ":", "-."]))
|
||||||
|
@ -135,7 +137,7 @@ def plot_main():
|
||||||
smooth_y = spline(smooth_x)
|
smooth_y = spline(smooth_x)
|
||||||
plt.plot_date(smooth_x, smooth_y, label=version, fmt=next(fmt))
|
plt.plot_date(smooth_x, smooth_y, label=version, fmt=next(fmt))
|
||||||
plt.xlabel("Date")
|
plt.xlabel("Date")
|
||||||
plt.ylabel("PyPI downloads")
|
plt.ylabel("PyPI daily downloads")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig("python-versions.png")
|
plt.savefig("python-versions.png")
|
||||||
|
|
||||||
|
@ -166,25 +168,27 @@ def plot_pct():
|
||||||
versions.groupby("start_date").agg(monthly_downloads=("download_count", "sum")),
|
versions.groupby("start_date").agg(monthly_downloads=("download_count", "sum")),
|
||||||
on="start_date",
|
on="start_date",
|
||||||
)
|
)
|
||||||
versions["pct"] = 100 * versions.download_count / versions.monthly_downloads
|
versions["pct"] = versions.download_count / versions.monthly_downloads
|
||||||
versions["date"] = pd.to_datetime(versions.start_date) + timedelta(days=14)
|
versions["date"] = pd.to_datetime(versions.start_date).dt.to_period('M')
|
||||||
versions.set_index(["Python version", "date"], inplace=True)
|
versions.set_index(["Python version", "date"], inplace=True)
|
||||||
to_plot = versions.pct.unstack(0, fill_value=0)
|
to_plot = versions.pct.unstack(0, fill_value=0)
|
||||||
to_plot.sort_values(
|
to_plot.sort_values(
|
||||||
by="Python version", ascending=False, axis=1, inplace=True, key=by_versions
|
by="Python version", ascending=False, axis=1, inplace=True, key=by_versions
|
||||||
)
|
)
|
||||||
|
pd.options.display.float_format = '{:.2%}'.format
|
||||||
print(to_plot.tail(24))
|
print(to_plot.tail(24))
|
||||||
for version in HIDE:
|
for version in HIDE:
|
||||||
del to_plot[version]
|
del to_plot[version]
|
||||||
del to_plot["Other"]
|
del to_plot["Other"]
|
||||||
plt.style.use("tableau-colorblind10")
|
plt.style.use("tableau-colorblind10")
|
||||||
to_plot.plot.area(
|
ax = to_plot.plot.area(
|
||||||
stacked=True,
|
stacked=True,
|
||||||
figsize=(10, 10 * 2 / 3),
|
figsize=(10, 10 * 2 / 3),
|
||||||
title="% of PyPI download by Python version",
|
title="% of PyPI download by Python version",
|
||||||
legend="reverse",
|
legend="reverse",
|
||||||
ylabel="%",
|
ylabel="%",
|
||||||
)
|
)
|
||||||
|
ax.yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1))
|
||||||
plt.savefig("python-versions-pct.png")
|
plt.savefig("python-versions-pct.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue