<jupyter_start><jupyter_text>Note* Instructions have been included for each segment. You do not have to follow them exactly, but they are included to help you think through the steps.<jupyter_code># Dependencies and Setup
import pandas as pd

# File to Load (Remember to Change These)
file_to_load = "Resources/purchase_data.csv"

# Read Purchasing File and store into Pandas data frame
purchase_data = pd.read_csv(file_to_load)<jupyter_output><empty_output><jupyter_text>Player Count<jupyter_code>purchase_data.head()<jupyter_output><empty_output><jupyter_text>* Display the total number of players<jupyter_code>unique_SN = len(purchase_data["SN"].unique())
unique_SN_df = pd.DataFrame({"Total Players": [unique_SN]})
unique_SN_df<jupyter_output><empty_output><jupyter_text>Purchasing Analysis (Total) * Run basic calculations to obtain number of unique items, average price, etc.* Create a summary data frame to hold the results* Optional: give the displayed data cleaner formatting* Display the summary data frame<jupyter_code>purchase_data.info()
unique_items = len(purchase_data["Item Name"].unique())
average_price = '${:,.2f}'.format(purchase_data["Price"].mean())
number_of_purchases = len(purchase_data["Purchase ID"].unique())
total_revenue = '${:,.2f}'.format(purchase_data["Price"].sum())
unique_items_df = pd.DataFrame({"Number of Unique Items": [unique_items],
                               "Average Price": [average_price],
                               "Number of Purchases": [number_of_purchases],
                               "Total Revenue": [total_revenue]})
unique_items_df<jupyter_output><empty_output><jupyter_text>Gender Demographics * Percentage and Count of Male Players* Percentage and Count of Female Players* Percentage and Count of Other / Non-Disclosed<jupyter_code>gender_counts = purchase_data["Gender"].value_counts()
gender_percent = purchase_data["Gender"].value_counts()/len(purchase_data["Gender"])
gender_counts_df = pd.DataFrame(gender_counts)
demo_df = gender_counts_df.rename(columns={"Gender":"Total Count"})
demo_df['Percentage of Players'] = gender_percent
demo_df<jupyter_output><empty_output><jupyter_text>Purchasing Analysis (Gender) * Run basic calculations to obtain purchase count, avg. purchase price, avg. purchase total per person etc. by gender* Create a summary data frame to hold the results* Optional: give the displayed data cleaner formatting* Display the summary data frame<jupyter_code>grouped_df = purchase_data.groupby(['Gender'])

purchase_count = grouped_df["Purchase ID"].count()
average_price = grouped_df["Price"].mean()
total_purchase = grouped_df["Price"].sum()
#avg_total_pp = total_purchase/gender_counts
#avg_total_pp

summary_df=pd.DataFrame({"Purchase Count":purchase_count,
                        "Average Purchase Price":average_price,
                        "Total Purchase Value": total_purchase,
                        "Avg Total Purchase per Person": total_purchase })

summary_df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10370123374458153, 'fraction_numerical': 0.0006668889629876625, 'mean_word_length': 5.521739130434782, 'pattern_counts': {'":': 10, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '113146', 'license': 'ADSL', 'n_tokens_mistral': 922, 'n_tokens_neox': 880, 'n_words': 229, 'path': 'HeroesOfPymoli/checkpoints/checkpoint2.ipynb', 'repo_name': 'drewrya/pandas-challenge', 'size': '2999'}