<jupyter_start><jupyter_text>Еspresso (Home vs. Coffee Shop) Comparison of the cumulative costs over time.<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
# format
plt.style.use('fivethirtyeight')
plt.rcParams['figure.figsize'] = [16, 9]
plt.rcParams['axes.titlepad'] = 25
plt.rcParams['axes.titlesize'] = 16
plt.rcParams['axes.titleweight'] = 700
plt.rcParams['axes.labelpad'] = 20
plt.rcParams['axes.labelsize'] = 14
plt.rcParams['axes.labelweight'] = 700
plt.rcParams['legend.fontsize'] = 11
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['savefig.bbox'] = 'tight'
plt.rcParams['savefig.pad_inches'] = 0.35<jupyter_output><empty_output><jupyter_text>An ExampleYour capsule espresso machine costs \\$295.  One can of 21 espresso capsules costs \\$19, which means one capsule costs \\$0.9.  We're adding 20% to that price for electricity, water and maintenance which bring one capsule to \\$1.08.  The price of an espresso shot at your nearest coffee shop is \\$1.75.<jupyter_code>starting_expense = 295
capsule = 19 / 21
price_per_capsule = capsule + (capsule * 0.2)

home_prices = [starting_expense]
for i in range(599):
    home_prices.append(home_prices[i] + price_per_capsule)

cafee_prices = [0]
for i in range(599):
    cafee_prices.append(cafee_prices[i] + 1.75)
days = [i for i in range(600)]

for i in range(len(days)):
    if home_prices[i] <= cafee_prices[i]:
        days_meeting_point = days[i]
        price_meeting_point = home_prices[i]
        print(price_meeting_point)
        print(days_meeting_point)
        break
title = 'Preparing Espresso Capsules at Home vs. Buying Espresso\
in a Coffee Shop\n(Comparison of the Cumulative Costs over Time)'

home_text = 'One box of 21 espresso capsules costs $19,\
\nwhich means one capsule costs $0.9. If on\
\ntop of that we add 20% (cost for electricity, water\
\nand maintenance) the realistic price for preparing\
\none espresso capsule at home is $1.08, which is\
\nthe daily incremental cost for this option. The\
\nstarting cumulative cost is $295, which\
\nis the cost of the espresso machine itself.'

coffee_shop_text = 'We\'re assuming the price of one espresso\
\ncup in a coffee shop is $1.75, which is\
\nthe incremental cost per day for this option.'

conclusion_text = f'Given the parameters, it\
\ntakes {days_meeting_point} days for preparing\
\nespresso at home to become\
\ncheaper than simply buying\
\na shot of espresso at the\
\nlocal coffee shop.'

plt.plot(days, home_prices, label='Preparing espresso capsulles at home')
plt.plot(days, cafee_prices, label='Buying espresso in a coffee shop')
plt.title(title)
plt.xlabel('Days')
plt.ylabel('Cumulative Expenses ($)')
plt.axvline(x=days_meeting_point, color='k', ls='--', lw='1.5')
plt.axhline(y=price_meeting_point, color='k', ls='--', lw='1.5')
plt.text(230, 340, fontsize=12, fontweight=700, s='At home:')

plt.text(230, 50, fontsize=12, 
         bbox=dict(boxstyle='round', fc='w', ec='k', pad=0.8), 
         s=f'{home_text}')

plt.text(12, 690, fontsize=12, fontweight=700, s='In a coffee shop:')

plt.text(12, 570, fontsize=12, 
         bbox=dict(boxstyle='round', fc='w', ec='k', pad=0.8), 
         s=f'{coffee_shop_text}')

plt.text(470, 520, fontsize=12, fontweight=700, s='Conclusion:')

plt.text(470, 300, fontsize=12, 
         bbox=dict(boxstyle='round', fc='w', ec='k', pad=0.8), 
         s=f'{conclusion_text}')

plt.annotate(f'{days_meeting_point} days', 
             xy=(days_meeting_point, price_meeting_point), 
             xytext=(525, 650), fontweight=700, 
             arrowprops=dict(fc='k', width=1, shrink=0.03))

plt.annotate('', fontsize=12, ha='center', 
             xy=(days[300], home_prices[300]),
             xytext=(350, 321), arrowprops=dict(fc='k', width=1))

plt.annotate('', fontsize=12, ha='center', 
             xy=(days[100], cafee_prices[100]), 
             xytext=(100, 542), arrowprops=dict(fc='k', width=1))

plt.legend(loc='upper left', bbox_to_anchor=(0.047, 0.95), 
           fontsize=12, borderpad=0.8, facecolor='w', edgecolor='k')

plt.show()<jupyter_output><empty_output><jupyter_text>Let's Build a TableLet's build a DataFrame with wide range of homemade espresso shot prices as index, and espresso machine prices as features and see how they intersect.<jupyter_code>machines = [i * 50 for i in range (2, 21)]
# machines
shots = [i / 10 for i in range(4, 15)]
# shots
time_range = [i for i in range(4000)]
dataset = {shot:[] for shot in shots}
# data
baseline = [0]
for i in range(len(time_range) - 1):
    baseline.append(baseline[i] + 1.75)

for shot in shots:
    for machine in machines:
        value = machine
        meeting_point = 0
        for i in range(len(time_range) - 1):
            if value <= baseline[i]:
                meeting_point = time_range[i]
                break
            value += shot
        dataset[shot].append(meeting_point)
df = pd.DataFrame(dataset, columns=shots, index=machines)
df.T<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13820811570912012, 'fraction_numerical': 0.043993571715548414, 'mean_word_length': 3.9889779559118237, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '288050', 'license': 'MIT', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1741, 'n_words': 480, 'path': 'espresso.ipynb', 'repo_name': 'vlatan/espresso', 'size': '4978'}