{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "operations = pd.read_csv(\"./00020510001.csv\")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "operations[\"Date\"] = pd.to_datetime(operations[\"Date\"])\n", "operations[\"Date de valeur\"] = pd.to_datetime(operations[\"Date de valeur\"])" ] }, { "cell_type": "code", "execution_count": 129, "metadata": {}, "outputs": [], "source": [ "postes = {\n", " \"autoroute\": [\"AUTOROUTE\", \"APRR\"],\n", " \"essence\": [\"CARBU\", \"TOTAL\", \"ESSFLO\", \"STATION\", \"AVIA\", ],\n", " \"bouffe\": [\"BIOCOOP\", \"LA VIE CLAIRE\", \"MAISON VITALE\", \"BOUCHERIE\", \"SALAISON CHALAM\", \"INTERMARCHE\", \"LA FERME DU COIN\",],\n", " \"bio\": [\"BIOCOOP\", \"LA VIE CLAIRE\", \"MAISON VITALE\"],\n", "}" ] }, { "cell_type": "code", "execution_count": 103, "metadata": {}, "outputs": [], "source": [ "def select_mots(df, colname, mots, inverse=False):\n", " if inverse:\n", " return df[~df[colname].str.contains('|'.join(mots))]\n", " return df[df[colname].str.contains('|'.join(mots))]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Mois d'octobre\n", "\n", "On est parti en Corse espéront que ça explique tout..." ] }, { "cell_type": "code", "execution_count": 107, "metadata": {}, "outputs": [], "source": [ "oct_op = operations[(operations[\"Date\"] >= \"2018-10\") & (operations[\"Date\"] < \"2018-11\")]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Total des dépenses" ] }, { "cell_type": "code", "execution_count": 108, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-1919.1499999999999" ] }, "execution_count": 108, "metadata": {}, "output_type": "execute_result" } ], "source": [ "oct_depenses = oct_op[oct_op[\"Montant\"]<0]\n", "oct_depenses[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Retraits" ] }, { "cell_type": "code", "execution_count": 109, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-360.0" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", [\"RETRAIT\"])[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Paiement par carte" ] }, { "cell_type": "code", "execution_count": 110, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-1426.02" ] }, "execution_count": 110, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", [\"PAIEMENT\"])[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dont autoroute" ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
182018-10-122018-10-12-10.6PAIEMENT CB 1110 21850 ST APOL APRR CARTE 7414...221.64
212018-10-152018-10-15-13.8PAIEMENT CB 1410 BERSAILLIN APRR CARTE 36045419133.29
252018-10-152018-10-15-2.8PAIEMENT CB 1410 PARIS RHIN RH APRR CARTE 3604...-80.05
432018-10-222018-10-22-9.0PAIEMENT CB 1910 21850 APRR CARTE 36045419751.36
442018-10-222018-10-22-23.8PAIEMENT CB 2110 VEDENE AUTOROUTE DU SUD CARTE...727.56
652018-10-312018-10-31-17.2PAIEMENT CB 2910 VEDENE AUTOROUTE DU SUD CARTE...353.13
\n", "
" ], "text/plain": [ " Date Date de valeur Montant \\\n", "18 2018-10-12 2018-10-12 -10.6 \n", "21 2018-10-15 2018-10-15 -13.8 \n", "25 2018-10-15 2018-10-15 -2.8 \n", "43 2018-10-22 2018-10-22 -9.0 \n", "44 2018-10-22 2018-10-22 -23.8 \n", "65 2018-10-31 2018-10-31 -17.2 \n", "\n", " Libellé Solde \n", "18 PAIEMENT CB 1110 21850 ST APOL APRR CARTE 7414... 221.64 \n", "21 PAIEMENT CB 1410 BERSAILLIN APRR CARTE 36045419 133.29 \n", "25 PAIEMENT CB 1410 PARIS RHIN RH APRR CARTE 3604... -80.05 \n", "43 PAIEMENT CB 1910 21850 APRR CARTE 36045419 751.36 \n", "44 PAIEMENT CB 2110 VEDENE AUTOROUTE DU SUD CARTE... 727.56 \n", "65 PAIEMENT CB 2910 VEDENE AUTOROUTE DU SUD CARTE... 353.13 " ] }, "execution_count": 111, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", postes[\"autoroute\"])" ] }, { "cell_type": "code", "execution_count": 112, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-77.2" ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dont essence" ] }, { "cell_type": "code", "execution_count": 130, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
112018-10-082018-10-08-56.54PAIEMENT CB 0610 EPAGNY AUCHAN CARBURANT CARTE...502.95
172018-10-122018-10-12-89.62PAIEMENT CB 1110 ARBENT ESSFLOREALYG341 CARTE ...232.24
322018-10-182018-10-18-47.28PAIEMENT CB 1710 ST CLAUDE STATION TOTAL CARTE...406.01
372018-10-222018-10-22-96.43PAIEMENT CB 1910 ARBENT ESSFLOREALYG341 CARTE ...866.38
\n", "
" ], "text/plain": [ " Date Date de valeur Montant \\\n", "11 2018-10-08 2018-10-08 -56.54 \n", "17 2018-10-12 2018-10-12 -89.62 \n", "32 2018-10-18 2018-10-18 -47.28 \n", "37 2018-10-22 2018-10-22 -96.43 \n", "\n", " Libellé Solde \n", "11 PAIEMENT CB 0610 EPAGNY AUCHAN CARBURANT CARTE... 502.95 \n", "17 PAIEMENT CB 1110 ARBENT ESSFLOREALYG341 CARTE ... 232.24 \n", "32 PAIEMENT CB 1710 ST CLAUDE STATION TOTAL CARTE... 406.01 \n", "37 PAIEMENT CB 1910 ARBENT ESSFLOREALYG341 CARTE ... 866.38 " ] }, "execution_count": 130, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", postes[\"essence\"])" ] }, { "cell_type": "code", "execution_count": 114, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-289.87" ] }, "execution_count": 114, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Le bio" ] }, { "cell_type": "code", "execution_count": 125, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
52018-10-012018-10-01-10.04PAIEMENT CB 2809 ST CLAUDE LA VIE CLAIRE CARTE...362.24
222018-10-152018-10-15-74.25PAIEMENT CB 1210 DORLISHEIM LA MAISON VITALE C...59.04
\n", "
" ], "text/plain": [ " Date Date de valeur Montant \\\n", "5 2018-10-01 2018-10-01 -10.04 \n", "22 2018-10-15 2018-10-15 -74.25 \n", "\n", " Libellé Solde \n", "5 PAIEMENT CB 2809 ST CLAUDE LA VIE CLAIRE CARTE... 362.24 \n", "22 PAIEMENT CB 1210 DORLISHEIM LA MAISON VITALE C... 59.04 " ] }, "execution_count": 125, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", postes[\"bio\"])" ] }, { "cell_type": "code", "execution_count": 126, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-84.28999999999999" ] }, "execution_count": 126, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Les courses courantes" ] }, { "cell_type": "code", "execution_count": 127, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
52018-10-012018-10-01-10.04PAIEMENT CB 2809 ST CLAUDE LA VIE CLAIRE CARTE...362.24
62018-10-012018-10-01-39.65PAIEMENT CB 2809 LA PESSE BOUCHERIE GRENA CART...322.59
122018-10-082018-10-08-6.90PAIEMENT CB 0510 LA PESSE SALAISON CHALAM CART...496.05
162018-10-112018-10-11-11.69PAIEMENT CB 0910 LA PESSE BOUCHERIE GRENA CART...321.86
222018-10-152018-10-15-74.25PAIEMENT CB 1210 DORLISHEIM LA MAISON VITALE C...59.04
312018-10-182018-10-18-23.06PAIEMENT CB 1710 ST CLAUDE CED INTERMARCHE CAR...453.29
402018-10-222018-10-22-24.72PAIEMENT CB 1910 CHATUZANGE LE LA FERME DU COI...833.06
\n", "
" ], "text/plain": [ " Date Date de valeur Montant \\\n", "5 2018-10-01 2018-10-01 -10.04 \n", "6 2018-10-01 2018-10-01 -39.65 \n", "12 2018-10-08 2018-10-08 -6.90 \n", "16 2018-10-11 2018-10-11 -11.69 \n", "22 2018-10-15 2018-10-15 -74.25 \n", "31 2018-10-18 2018-10-18 -23.06 \n", "40 2018-10-22 2018-10-22 -24.72 \n", "\n", " Libellé Solde \n", "5 PAIEMENT CB 2809 ST CLAUDE LA VIE CLAIRE CARTE... 362.24 \n", "6 PAIEMENT CB 2809 LA PESSE BOUCHERIE GRENA CART... 322.59 \n", "12 PAIEMENT CB 0510 LA PESSE SALAISON CHALAM CART... 496.05 \n", "16 PAIEMENT CB 0910 LA PESSE BOUCHERIE GRENA CART... 321.86 \n", "22 PAIEMENT CB 1210 DORLISHEIM LA MAISON VITALE C... 59.04 \n", "31 PAIEMENT CB 1710 ST CLAUDE CED INTERMARCHE CAR... 453.29 \n", "40 PAIEMENT CB 1910 CHATUZANGE LE LA FERME DU COI... 833.06 " ] }, "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", postes[\"bouffe\"])" ] }, { "cell_type": "code", "execution_count": 128, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-190.31" ] }, "execution_count": 128, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Autres que les paiements et retraits" ] }, { "cell_type": "code", "execution_count": 115, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
72018-10-022018-10-02-23.10HABITAT BQ6459900 1827599 BQ6459900299.49
92018-10-052018-10-01-6.25F FRAIS BANCAIRES MENSUALISES593.24
262018-10-152018-11-14-16.00F COMM INTERVENTION 6 OPER-96.05
292018-10-172018-10-17-22.00VIR SEPA JULIE AVELLANA176.35
582018-10-302018-10-30-65.78AUTOMOBILE AA000000020508691 RMS18302072583746HI680.12
\n", "
" ], "text/plain": [ " Date Date de valeur Montant \\\n", "7 2018-10-02 2018-10-02 -23.10 \n", "9 2018-10-05 2018-10-01 -6.25 \n", "26 2018-10-15 2018-11-14 -16.00 \n", "29 2018-10-17 2018-10-17 -22.00 \n", "58 2018-10-30 2018-10-30 -65.78 \n", "\n", " Libellé Solde \n", "7 HABITAT BQ6459900 1827599 BQ6459900 299.49 \n", "9 F FRAIS BANCAIRES MENSUALISES 593.24 \n", "26 F COMM INTERVENTION 6 OPER -96.05 \n", "29 VIR SEPA JULIE AVELLANA 176.35 \n", "58 AUTOMOBILE AA000000020508691 RMS18302072583746HI 680.12 " ] }, "execution_count": 115, "metadata": {}, "output_type": "execute_result" } ], "source": [ "select_mots(oct_depenses, \"Libellé\", [\"PAIEMENT\", \"RETRAIT\"], inverse=True)" ] }, { "cell_type": "code", "execution_count": 116, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-133.13" ] }, "execution_count": 116, "metadata": {}, "output_type": "execute_result" } ], "source": [ "_[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Mois de Novembre " ] }, { "cell_type": "code", "execution_count": 117, "metadata": {}, "outputs": [], "source": [ "nov_op = operations[(operations[\"Date\"] >= \"2018-11\") & (operations[\"Date\"] < \"2018-12\")]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Total des dépenses" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-1108.68" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nov_depenses = nov_op[nov_op[\"Montant\"]<0]\n", "nov_depenses[\"Montant\"].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Retraits" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-200.0" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nov_depenses[nov_depenses[\"Libellé\"].str.contains(\"RETRAIT\")]['Montant'].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Paiements directs" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-878.0299999999999" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "nov_depenses[nov_depenses[\"Libellé\"].str.contains(\"PAIEMENT\")]['Montant'].sum()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Autres" ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DateDate de valeurMontantLibelléSolde
662018-11-012018-11-01-11.00VIR SEPA PARTAGE INTERNET342.13
682018-11-022018-11-02-13.40HABITAT BQ6459900 1830699 BQ6459900326.83
732018-11-062018-11-01-6.25F FRAIS BANCAIRES MENSUALISES186.38
\n", "
" ], "text/plain": [ " Date Date de valeur Montant Libellé \\\n", "66 2018-11-01 2018-11-01 -11.00 VIR SEPA PARTAGE INTERNET \n", "68 2018-11-02 2018-11-02 -13.40 HABITAT BQ6459900 1830699 BQ6459900 \n", "73 2018-11-06 2018-11-01 -6.25 F FRAIS BANCAIRES MENSUALISES \n", "\n", " Solde \n", "66 342.13 \n", "68 326.83 \n", "73 186.38 " ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "autres = nov_depenses[~nov_depenses[\"Libellé\"].str.contains(\"PAIEMENT\") & ~nov_depenses[\"Libellé\"].str.contains(\"RETRAIT\")]\n", "autres" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-30.65" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "autres[\"Montant\"].sum()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }