From 9c109c10564c8165f131954ce7c8f2af47a331e7 Mon Sep 17 00:00:00 2001 From: Alexeijugin <57283269+Alexeijugin@users.noreply.github.com> Date: Thu, 3 Sep 2026 14:28:49 +0300 Subject: [PATCH] python_1 --- .gitignore | 1 + count_sum_pandas.py | 21 +++++++++++++++++++++ requirements.txt | Bin 0 -> 178 bytes 3 files changed, 22 insertions(+) create mode 100644 .gitignore create mode 100644 count_sum_pandas.py create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/count_sum_pandas.py b/count_sum_pandas.py new file mode 100644 index 0000000..8b5cca9 --- /dev/null +++ b/count_sum_pandas.py @@ -0,0 +1,21 @@ +import pandas as pd + +def count_sum(df: pd.DataFrame) -> pd.DataFrame: + result = df.groupby("Товар")[["Количество"]].sum() + return result + + +data = { + "Дата": ["07.05.2022", "07.05.2022", "08.05.2022", "08.05.2022"], + "Товар": ["Банан", "Хлеб", "Банан", "Хлеб"], + "Количество": [30, 10, 40, 8] +} +input_df = pd.DataFrame(data) + +print(input_df) + + +output_df = count_sum(input_df) + +print() +print(output_df) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..dfe091d2a708340f35c1b7238ac54bdeade7fe4b GIT binary patch literal 178 zcmX|*K?=e!6a{Bp@F+@}P>Tx>Q)od!V;~V)4{v?_4HA;YpZP=9Z{*FB#KKj_bE4Dr z9B4Ehh>Uu((IDc?*y%#y#!Jr8tiq&P;m+ebWiYHO$s Lr{A2#gKho*eDWIJ literal 0 HcmV?d00001