<jupyter_start><jupyter_text>Challenge: first combine these sales together into a single dataframe, then compute how much money consumers spent on each book in each currency.<jupyter_code>df1 = sales1.rename(columns={
    'Book title': 'title',
    'Number sold': 'number',
    'Sales price': 'their_price',
    'Royalty paid': 'we_got',
    })
df1['currency'] = 'USD'
df1
s = sales2.copy()
t = sales2['Title']
t = t.where(t.str.endswith(')')).str.split().str[-1].str.strip('()')
s['currency'] = t.fillna(method='bfill')
s = s[s['List price'].notnull()]
df2 = s.rename(columns={
    'Units sold': 'number',
    'Title': 'title',
    'List price': 'their_price',
    'Royalty': 'we_got',
    })
s.head()
df = pd.concat([df1, df2])
df
df['total_paid'] = df.their_price * df.number
df.groupby(['title', 'currency'])[['total_paid']].sum()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2037037037037037, 'fraction_numerical': 0.011574074074074073, 'mean_word_length': 4.924657534246576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '122022', 'license': 'MIT', 'n_tokens_mistral': 323, 'n_tokens_neox': 318, 'n_words': 72, 'path': 'Exercises-6.ipynb', 'repo_name': 'jlvengo/pandas-deep-dive', 'size': '864'}