Q8A & Q8B: Using the castaway_details data, what is the percentage of total extroverts and introverts that have played the game (count players only once even if they have played in more than one season). Do not count contestants without a personality type listed in your calculations. Save these percentages as Q8A and Q8B respectively. Note: Round all percentages to two decimal points and write as a float (example: 55.57) using python code

1 answer

To calculate the percentage of total extroverts and introverts who have played the game, we need to first filter out the contestants without a personality type listed. Then, we can calculate the percentage by dividing the count of extroverts/introverts by the total number of players.

Here is the Python code to calculate these percentages:

```python
import pandas as pd

# Read the castaway_details data into a pandas dataframe
castaway_details = pd.read_csv('castaway_details.csv')

# Filter out contestants without a personality type listed
filtered_castaways = castaway_details.dropna(subset=['personality_type'])

# Calculate the percentage of extroverts
extroverts_count = filtered_castaways['personality_type'].str.contains('E').sum()
total_players = filtered_castaways['name'].nunique()
Q8A = round((extroverts_count / total_players) * 100, 2)

# Calculate the percentage of introverts
introverts_count = filtered_castaways['personality_type'].str.contains('I').sum()
Q8B = round((introverts_count / total_players) * 100, 2)

print("Percentage of total extroverts:", Q8A)
print("Percentage of total introverts:", Q8B)
```

Note: Ensure that the file name and the column names in the code match your dataset.