Last active
January 2, 2020 21:38
-
-
Save knowsuchagency/c4920f62c40e20783c089341ecd143d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Transaction Date</th>\n", | |
" <th>Posted Date</th>\n", | |
" <th>Description</th>\n", | |
" <th>Debit</th>\n", | |
" <th>Credit</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>116</th>\n", | |
" <td>7/11/2019</td>\n", | |
" <td>7/12/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>56.82</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>75</th>\n", | |
" <td>9/9/2019</td>\n", | |
" <td>9/10/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>66.72</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>265</th>\n", | |
" <td>8/9/2019</td>\n", | |
" <td>8/12/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>68.47</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>60</th>\n", | |
" <td>12/11/2019</td>\n", | |
" <td>12/12/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>76.21</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>127</th>\n", | |
" <td>11/8/2019</td>\n", | |
" <td>11/11/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>65.32</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>225</th>\n", | |
" <td>10/10/2019</td>\n", | |
" <td>10/11/2019</td>\n", | |
" <td>PGE WEBRECURRING 800-743-5000 CA</td>\n", | |
" <td>44.17</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Transaction Date Posted Date Description Debit \\\n", | |
"116 7/11/2019 7/12/2019 PGE WEBRECURRING 800-743-5000 CA 56.82 \n", | |
"75 9/9/2019 9/10/2019 PGE WEBRECURRING 800-743-5000 CA 66.72 \n", | |
"265 8/9/2019 8/12/2019 PGE WEBRECURRING 800-743-5000 CA 68.47 \n", | |
"60 12/11/2019 12/12/2019 PGE WEBRECURRING 800-743-5000 CA 76.21 \n", | |
"127 11/8/2019 11/11/2019 PGE WEBRECURRING 800-743-5000 CA 65.32 \n", | |
"225 10/10/2019 10/11/2019 PGE WEBRECURRING 800-743-5000 CA 44.17 \n", | |
"\n", | |
" Credit \n", | |
"116 NaN \n", | |
"75 NaN \n", | |
"265 NaN \n", | |
"60 NaN \n", | |
"127 NaN \n", | |
"225 NaN " | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from pathlib import Path\n", | |
"\n", | |
"import pandas as pd\n", | |
"\n", | |
"csvs = Path(Path.home(), 'Downloads').glob('transactions*.CSV')\n", | |
"\n", | |
"frames = [pd.read_csv(p) for p in csvs]\n", | |
"\n", | |
"df = pd.concat(frames)\n", | |
"\n", | |
"pge = df[df.Description.map(lambda s: 'PGE WEBRECURRING' in s)]\n", | |
"\n", | |
"pge" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"PG&E cost per-person since June:\n", | |
"$94.43\n" | |
] | |
} | |
], | |
"source": [ | |
"print(\"PG&E cost per-person since June:\\n${:.2f}\".format(pge.Debit.sum() / 4))" | |
] | |
}, | |
{ | |
"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.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment