Skip to content

Instantly share code, notes, and snippets.

@billtubbs
Last active March 29, 2020 02:40
Show Gist options
  • Save billtubbs/939b3d348a8329fb29e3c8d451e50a74 to your computer and use it in GitHub Desktop.
Save billtubbs/939b3d348a8329fb29e3c8d451e50a74 to your computer and use it in GitHub Desktop.
Excel-vs-Python.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"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>Food</th>\n",
" <th>Car</th>\n",
" <th>Fuel</th>\n",
" <th>Tickets</th>\n",
" <th>Other</th>\n",
" <th>Total Paid</th>\n",
" <th>Owing</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Diane</th>\n",
" <td>38.15</td>\n",
" <td>139</td>\n",
" <td>25.08</td>\n",
" <td>0</td>\n",
" <td>95</td>\n",
" <td>297.23</td>\n",
" <td>-33.57</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Kelly</th>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>134</td>\n",
" <td>0</td>\n",
" <td>134.00</td>\n",
" <td>129.66</td>\n",
" </tr>\n",
" <tr>\n",
" <th>John</th>\n",
" <td>109.75</td>\n",
" <td>0</td>\n",
" <td>0.00</td>\n",
" <td>0</td>\n",
" <td>250</td>\n",
" <td>359.75</td>\n",
" <td>-96.09</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Food Car Fuel Tickets Other Total Paid Owing\n",
"Diane 38.15 139 25.08 0 95 297.23 -33.57\n",
"Kelly 0.00 0 0.00 134 0 134.00 129.66\n",
"John 109.75 0 0.00 0 250 359.75 -96.09"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Calculate amount owing\n",
"df['Total Paid'] = df.sum(axis=1)\n",
"average_cost = df['Total Paid'].mean()\n",
"df['Owing'] = (average_cost - df['Total Paid'])\n",
"df"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (tf)",
"language": "python",
"name": "tf"
},
"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.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment