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).

1 answer

To calculate the percentage of total extroverts that have played the game, we need to divide the number of extroverts by the total number of players (excluding contestants without a personality type listed), and then multiply the result by 100.

First, let's count the number of extroverts:
```python
extroverts = castaway_details[castaway_details['Personality Type'] == 'Extrovert']
total_extroverts = len(extroverts)
```

Next, let's count the total number of players by excluding contestants without a personality type listed:
```python
players = castaway_details.dropna(subset=['Personality Type'])
total_players = len(players)
```

Finally, we can calculate the percentage of extroverts as Q8A:
```python
Q8A = (total_extroverts / total_players) * 100
```

For the percentage of introverts, we can follow the same steps. Let's count the number of introverts first:
```python
introverts = castaway_details[castaway_details['Personality Type'] == 'Introvert']
total_introverts = len(introverts)
```

And then calculate the percentage of introverts as Q8B:
```python
Q8B = (total_introverts / total_players) * 100
```

Round the percentages to two decimal points and save them as floats:
```python
Q8A = round(Q8A, 2)
Q8B = round(Q8B, 2)
```

The final values of Q8A and Q8B are the percentages of total extroverts and introverts that have played the game, respectively.