add analysis module

This commit is contained in:
schaermicha1 committed 2026-03-12 15:07:47 +01:00
1 parent 86d0d6582d
commit fb97703cdd
11 files changed
+44

No files matched your search

View File
Whitespace-only changes.
+13
View File
@@ -0,0 +1,13 @@
from analysis.io import load_sales
from analysis.metrics import revenue_per_day
from analysis.plotting import plot_daily_revenue
def main() -> None:
df = load_sales("resources/sales.csv")
daily = revenue_per_day(df)
plot_daily_revenue(daily)
if __name__ == "__main__":
main()
+5
View File
@@ -0,0 +1,5 @@
import pandas as pd
def load_sales(path: str) -> pd.DataFrame:
return pd.read_csv(path, sep=",", encoding="utf-8")
+6
View File
@@ -0,0 +1,6 @@
import pandas as pd
def revenue_per_day(df: pd.DataFrame) -> pd.Series:
revenue = df["quantity"] * df["unit_price"]
return revenue.groupby(df["day"]).sum()
+9
View File
@@ -0,0 +1,9 @@
import matplotlib.pyplot as plt
import pandas as pd
def plot_daily_revenue(daily: pd.Series) -> None:
daily.plot(kind="bar")
plt.title("Daily Revenue")
plt.tight_layout()
plt.show()