<jupyter_start><jupyter_text>Player Count<jupyter_code>summary_df = pd.DataFrame({
    'Total Players':[unique_players['SN'].count()]
})
summary_df<jupyter_output><empty_output><jupyter_text>Item Analysis<jupyter_code>averageprice = unique_items['Price'].mean()
totalrev = purchase_data['Price'].sum()
pd.options.display.float_format = '${:,.2f}'.format

purchasing_analysis_df = pd.DataFrame({  
    'Number of Unique Items':unique_items['Item Name'].count(),
    "Average Price": averageprice,
    "Number of Purchases": [purchase_data['Purchase ID'].count()],
    "Total Revenue": totalrev,
})

purchasing_analysis_df<jupyter_output><empty_output><jupyter_text>Gender Demographics<jupyter_code>pd.options.display.float_format = '{:,.2f}%'.format

gender_demo = pd.DataFrame({
    'Total Count': unique_players['Gender'].value_counts(),  
    'Percentage of Players': (unique_players['Gender'].value_counts() / unique_players['SN'].count()) * 100
})
gender_demo<jupyter_output><empty_output><jupyter_text>Gender Spending Analysis<jupyter_code>gender_group = purchase_data.groupby('Gender')

avgpurpri = gender_group['Price'].mean()
totpurval = gender_group['Price'].sum()
avgtotpur = gender_group['Price'].sum() / unique_players['Gender'].value_counts()
pd.options.display.float_format = '${:,.2f}'.format

gender_purchase_df = pd.DataFrame({
    'Purchase Count':gender_group['Purchase ID'].count(),
    'Average Purchase Price':avgpurpri,
    'Total Purchase Value':totpurval,
    'Avg Total Purchase per Person':avgtotpur 
})

gender_purchase_df<jupyter_output><empty_output><jupyter_text><jupyter_code># create bins and labels for 'Age Ranges' column

bins = [0,9,14,19,24,29,34,39,99]
labels = ['<10','10-14','15-19','20-24','25-29','30-34','35-39','40+']


# adding 'Age Ranges' column to both dataframes
purchase_data['Age Ranges'] = pd.cut(purchase_data['Age'], bins = bins, labels = labels)
purchase_data = purchase_data[['Purchase ID','SN','Age','Age Ranges','Gender','Item ID','Item Name','Price']]

unique_players['Age Ranges'] = pd.cut(unique_players['Age'], bins = bins, labels = labels)
unique_players = unique_players[['SN','Age','Age Ranges','Gender']]

# grouping dataframes by 'Age Ranges'
purchase_group_age = purchase_data.groupby('Age Ranges')
player_group = unique_players.groupby('Age Ranges')<jupyter_output><empty_output><jupyter_text>Age Demographics<jupyter_code>pd.options.display.float_format = '{:,.2f}%'.format

age_demo_df = pd.DataFrame({
    'Total Count': player_group['SN'].count(),
    'Percentage of Players':(player_group['SN'].count() / unique_players['SN'].count()) * 100
})

age_demo_df<jupyter_output><empty_output><jupyter_text>Age Spending Analysis<jupyter_code>pd.options.display.float_format = '${:,.2f}'.format

age_purchase_df = pd.DataFrame ({
    'Purchase Count':purchase_group_age['Purchase ID'].count(),
    'Average Purchase Price':purchase_group_age['Price'].mean(),
    'Total Purchase Value':purchase_group_age['Price'].sum(),
    'Avg Total Purchase per Person':purchase_group_age['Price'].sum() / player_group['SN'].count()
})

age_purchase_df<jupyter_output><empty_output><jupyter_text>Top Spenders<jupyter_code>purchase_group_sn = purchase_data.groupby('SN')

pd.options.display.float_format = '${:,.2f}'.format
top_spenders_df = pd.DataFrame({
    'Purchase Count':purchase_group_sn['Purchase ID'].count(),
    'Average Purchase Price': purchase_group_sn['Price'].sum() / purchase_group_sn['Purchase ID'].count(),
    'Total Purchase Value':purchase_group_sn['Price'].sum(),
})


top_spenders_df.sort_values(by='Total Purchase Value', ascending = False).head(10)
print(unique_players.loc[unique_players['SN'] == 'Lisosia93'])
print(unique_players.loc[unique_players['SN'] == 'Idastidru52'])<jupyter_output><empty_output><jupyter_text>Most Profitable Items<jupyter_code>pd.options.display.float_format = '${:,.2f}'.format

pop_items_group = purchase_data.groupby(['Item ID','Item Name'])

top_items_df = pd.DataFrame({
    'Purchase Count':pop_items_group['Purchase ID'].count(),
    'Item Price':pop_items_group['Price'].max(),
    'Total Purchase Value':pop_items_group['Purchase ID'].count() * pop_items_group['Price'].max()
})

top_items_df.sort_values(by = 'Total Purchase Value', ascending = False).head()<jupyter_output><empty_output><jupyter_text>Most Profitable Items (Missing Item)<jupyter_code>pd.options.display.float_format = '${:,.2f}'.format

pop_items_group = purchase_data.groupby(['Item Name'])

top_items_df = pd.DataFrame({
    'Purchase Count':pop_items_group['Purchase ID'].count(),
    'Item Price':pop_items_group['Price'].max(),
    'Total Purchase Value':pop_items_group['Purchase ID'].count() * pop_items_group['Price'].max()
})

top_items_df.sort_values(by = 'Total Purchase Value', ascending = False).head(3)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17052980132450332, 'fraction_numerical': 0.013451986754966887, 'mean_word_length': 7.83546617915905, 'pattern_counts': {'":': 3, '<': 42, '<?xml version=': 0, '>': 41, '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': '597352', 'license': 'ADSL', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1666, 'n_words': 239, 'path': 'HeroesofPyMoli.ipynb', 'repo_name': 'daniel-valdes/pandas-challenge', 'size': '4832'}