<jupyter_start><jupyter_text>Ben and I moved to New Hampshire in August. We moved into a small cottage on his parents' new house property, and figured that because we weren't going to be paying rent we could splurge on house expenses. But we went kinda wild, so let's see if the gamble was right...<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
df = pd.read_csv('Claire and Ben moving costs - Sheet1.csv')

df.columns = ['_'.join(c.lower().split()) for c in df.columns]

df.head()<jupyter_output><empty_output><jupyter_text>First question, and the goal of this whole thing: are we settled up, or did one of us pay way more than the other?<jupyter_code>df['how_much'] = (
    df['how_much'].str.strip('$').str.replace(',', '').astype(float)
)
df.groupby('who_paid').sum()<jupyter_output><empty_output><jupyter_text>Wow, at the beginning we thought that Ben would have paid way more because he got all the Amazon stuff. But it looks like I've now outpaced him -- probably due to the couple of large expenses I paid for (couch, our part of the hut tub). Let's break it down by category and see how things stack up.<jupyter_code>(df.groupby(['category', 'who_paid']).sum()
   .reset_index() # get category, who paid, and total amount in columns
   .pivot(index='category', columns='who_paid', values='how_much') # reshape to get categories per row, person per columns; for plotting with pandas
   .plot(kind='bar') #, x='category', y='how_much', color='who_paid')
)<jupyter_output><empty_output><jupyter_text>Sure enough, I paid the \\$3000 for the hot tub/Ben's mom's bike and ~\\$2000 for the couch. If we remove these, how do we stack up? Moving expenses only<jupyter_code># Keep just appliances, house, kitchen, and moving expenses
keep_cats = ['appliances', 'house', 'kitchen', 'moving']

print(df.query('category == @keep_cats').groupby('who_paid').sum())

(df.query('category == @keep_cats')
   .groupby(['category', 'who_paid']).sum()
   .reset_index() # get category, who paid, and total amount in columns
   .pivot(index='category', columns='who_paid', values='how_much') # reshape to get categories per row, person per columns; for plotting with pandas
   .plot(kind='bar') #, x='category', y='how_much', color='who_paid')
)<jupyter_output>how_much
who_paid          
BP         3441.59
CD         2375.01<jupyter_text>Ok, so if we just look at the things that would be more directly considered as moving expenses, then Ben spent about \\$1000 more than I did.It's interesting that we did end up just about equaling out on moving expenses. We tried to go back and forth for the two weekends that we spent moving, but we weren't sure if it had evened out. Also wow moving is expensive -- a little over a thousand dollars to buy all the boxes and moving supplies, and to rent a truck for two weekends. I wonder how much hiring a moving crew would have cost, especially considering that spending two full weekends moving was _quite_ miserable and would be worth a lot of money to not have to repeat. But good to know how much it all added up to for next time we move, when we've both agreed to hire someone to help!Out of curiosity, how much of these expenses were the truck vs. other things?<jupyter_code>df.query('category == "moving"')<jupyter_output><empty_output><jupyter_text>Looks like about half of it was the moving truck: ~\\$300 each weekend, looks like.  An oxo tangentLol we spent almost as much on kitchen knick knacks than we did on our appliances! For appliances, we bought a fridge, toaster oven, microwave, and induction stove. But I guess that has no chance against the millions of Oxo and other kitchen gadgets we got!<jupyter_code>keep_cats = ['appliances', 'kitchen']
df.query('category == @keep_cats').groupby('category').sum()<jupyter_output><empty_output><jupyter_text>Speaking of Oxo... I joked to Ben that he was buying out every single Oxo item and that when we did this analysis we should see what percent of our expenses were Oxo. Unfortunately, getting that info would take way too long becuase we used his Amazon statements to get these expenses, and they don't show everything itemized. So instead, let's see how many of the kitchen-related orders included something Oxo (I made sure to write that down).<jupyter_code>df[df['for_what'].str.lower().str.contains('oxo')]<jupyter_output><empty_output><jupyter_text>Ahahah okay but actually a lot of these were just straight-up Oxo. Let's remove the one that contains the toaster oven (because the majority of that expense was the toaster oven itself), and see how much the rest adds up to.<jupyter_code># Oxo-only expenses
print(f"Oxo-only expenses = ${round(df[df['for_what'].str.lower() == 'oxo'].sum()['how_much'])}")
print(f"Expenses including Oxo = $ {round(df[df['for_what'].str.lower().str.contains('oxo')].sum()['how_much'] - 349.54)}")<jupyter_output>Oxo-only expenses = $102
Expenses including Oxo = $ 422<jupyter_text>So our Oxo expenses are somewhere between \\$100 and \\$400. Not bad, actually -- way less than I would have guessed!Ok last Oxo-focused question: what proportion of our kitchen-related expenses included Oxo products?<jupyter_code># Get total number of kitchen expenses
n_kitchen = df.query('category == "kitchen"').shape[0]

# Get number of expenses containing oxo
n_oxo = df['for_what'].str.lower().str.contains('oxo').sum()

print(f"Fraction of kitchen expenses containing oxo = {round(n_oxo/n_kitchen, 2)} ({n_oxo}/{n_kitchen})")<jupyter_output>Fraction of kitchen expenses containing oxo = 0.37 (11/30)<jupyter_text>Nice. Over a third of our kitchen expenses included something Oxo. We really just couldn't get enough!  Back to expensesOk, back to the overall expenses. One thing sticks out -- what on earth did we spend over \\$500 on "house" things for?<jupyter_code>df.query('category == "house"')['for_what'].unique()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10541358439811702, 'fraction_numerical': 0.009583053127101547, 'mean_word_length': 5.145661157024794, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '47861', 'license': 'MIT', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1734, 'n_words': 749, 'path': '_jupyter/2020-12-25-moving-expenses/2020-12-25-moving-expenses.ipynb', 'repo_name': 'KingJamesSong/KingJamesSong.github.io', 'size': '5948'}