<jupyter_start><jupyter_text>Remove all null values from RespondentID column<jupyter_code>star_wars = star_wars[star_wars['RespondentID'].notnull()]
star_wars.head()


star_wars['RespondentID'].isnull().sum()<jupyter_output><empty_output><jupyter_text>Convert the values of certain columns to booleans<jupyter_code>def convert_to_bool(repsonse):
    if repsonse.lower() == 'yes':
        return True
    elif repsonse.lower() == 'no':
        return False
    else:
        return np.nan
star_wars['Have you seen any of the 6 films in the Star Wars franchise?'] = star_wars['Have you seen any of the 6 films in the Star Wars franchise?'].apply(convert_to_bool)
star_wars['Have you seen any of the 6 films in the Star Wars franchise?'].value_counts()
# star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'] = star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].apply(convert_to_bool)

star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].value_counts()

star_wars['Have you seen any of the 6 films in the Star Wars franchise?'].value_counts(dropna=False)
star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].value_counts(dropna=False)

star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'] = star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].map({'Yes': True, 'No': False})
star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'].value_counts()


map_dict = { 
'Star Wars: Episode I  The Phantom Menace': True,
  'Star Wars: Episode II  Attack of the Clones': True,
  'Star Wars: Episode III  Revenge of the Sith': True,
  'Star Wars: Episode IV  A New Hope': True,
  'Star Wars: Episode V The Empire Strikes Back': True,
  'Star Wars: Episode VI Return of the Jedi': True,  
   np.nan: False
}

star_wars[star_wars.columns[3:9]] = star_wars[star_wars.columns[3:9]].apply(lambda column: column.map(map_dict), axis=0)


new_cols = {
     "Which of the following Star Wars films have you seen? Please select all that apply.": "seen_1",
     'Unnamed: 4': 'seen_2',
     'Unnamed: 5': 'seen_3',
     'Unnamed: 6': 'seen_4',
     'Unnamed: 7': 'seen_5',
     'Unnamed: 8': 'seen_6',
}
star_wars = star_wars.rename(columns=new_cols)
star_wars.columns<jupyter_output><empty_output><jupyter_text>Convert the ranking of the 6 movies to floats<jupyter_code>star_wars[star_wars.columns[9:15]] = star_wars[star_wars.columns[9:15]].astype(float)
star_wars.head()<jupyter_output><empty_output><jupyter_text>Rename the columns to reflect the titles being ranked<jupyter_code>title_map = {
    'Please rank the Star Wars films in order of preference with 1 being your favorite film in the franchise and 6 being your least favorite film.': 'Phantom Menace Rank',
    'Unnamed: 10': 'Attack of the Clones Rank',
    'Unnamed: 11': 'Revenge of the Sith Rank',
    'Unnamed: 12': 'A New Hope Rank',
    'Unnamed: 13': 'Empire Strikes Back Rank',
    'Unnamed: 14': 'Return of the Jedi Rank'

}
star_wars = star_wars.rename(columns = title_map)
star_wars.iloc[:,9:15].head()<jupyter_output><empty_output><jupyter_text>The mean of the 6 star wars films ranked<jupyter_code>star_wars.iloc[:,9:15].mean(axis=0)
%matplotlib inline
import matplotlib.pyplot as plt
star_wars.iloc[:,9:15].mean(axis=0).plot.bar()<jupyter_output><empty_output><jupyter_text>After converting the ranking of the 6 star wars films to floats and calcualting the means it shows that Episode V The Empire Strike Back ranks the highest while Episodes II and III rank the lowest. Suprisingly Episode IV A New Hope, the 1st of the orinal trilogy ranked the lowest for the orginal trilogy while Episode I ranked the highest of the newest trilogy.   The Total Sums of Which Star Wars Movie people had seen<jupyter_code>star_wars[star_wars.columns[3:9]].sum()
star_wars[star_wars.columns[3:9]].sum().plot.bar()<jupyter_output><empty_output><jupyter_text>From the responces in the survey we can see that a larger number of people responded to seeing episodes V, VI and I. It also correlates to the rankings above as Episode V was ranked the highest, it is also the most seen movie.<jupyter_code>males = star_wars[star_wars["Gender"] == "Male"]
females = star_wars[star_wars["Gender"] == "Female"]
star_wars_fan = star_wars[star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'] == True]
not_star_wars_fan = star_wars[star_wars['Do you consider yourself to be a fan of the Star Wars film franchise?'] == False]
star_trek_fan = star_wars[star_wars['Do you consider yourself to be a fan of the Star Trek franchise?'] == 'Yes']
not_star_trek_fan = star_wars[star_wars['Do you consider yourself to be a fan of the Star Trek franchise?'] == 'No']

males.head()

males_rank_mean = males.iloc[:,9:15].mean()
females_rank_mean = females.iloc[:,9:15].mean()
star_wars_fan_rank_mean = star_wars_fan.iloc[:,9:15].mean()
not_star_wars_fan_rank_mean = not_star_wars_fan.iloc[:,9:15].mean()
star_trek_fan_rank_mean = star_trek_fan.iloc[:,9:15].mean()
not_star_trek_fan_rank_mean = not_star_trek_fan.iloc[:,9:15].mean()
males_seen_sum = males.iloc[:,3:9].sum()
females_seen_sum = females.iloc[:,3:9].sum()
star_wars_fan_seen_sum = star_wars_fan.iloc[:,3:9].sum()
not_star_wars_fan_seen_sum = not_star_wars_fan.iloc[:,3:9].sum()
star_trek_fan_seen_sum = star_trek_fan.iloc[:,3:9].sum()
not_star_trek_fan_seen_sum = not_star_trek_fan.iloc[:,3:9].sum()<jupyter_output><empty_output><jupyter_text>Men vs. Women with Rank in 6 Star Wars Movies<jupyter_code>fig = plt.figure(figsize=(20, 6))
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
males_rank_mean.plot(kind='bar', ax=ax1, title='Men')
females_rank_mean.plot(kind='bar', ax=ax2, title='Women')
plt.show()<jupyter_output><empty_output><jupyter_text>Men vs. Women Have Seen 6 Star Wars Movies<jupyter_code>fig = plt.figure(figsize=(20, 6))
ax1 = fig.add_subplot(1, 2, 1)
ax2 = fig.add_subplot(1, 2, 2)
males_seen_sum.plot(kind='bar', ax=ax1, title='Men')
females_seen_sum.plot(kind='bar', ax=ax2, title='Women')
plt.show()<jupyter_output><empty_output><jupyter_text>Men have seen the more of The Star Wars movies. For both men and women the amount of movies seen directly correlates with the rankings they have the movies.  Star Wars Fans and Relation to seen & ranking<jupyter_code>fig = plt.figure(figsize=(20, 12))
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax4 = fig.add_subplot(2, 2, 4)
star_wars_fan_seen_sum.plot(kind='bar', ax=ax1, title='Fan Sum')
not_star_wars_fan_seen_sum.plot(kind='bar', ax=ax2, title='Non Fan Sum')
star_wars_fan_rank_mean.plot(kind='bar', ax=ax3, title='Fan Rank')
not_star_wars_fan_rank_mean.plot(kind='bar', ax=ax4, title='Non Fan Rank')
plt.show()<jupyter_output><empty_output><jupyter_text>Star Wars fans rank the moves similarly the overall ratings. There are some differences in non fans as they enojoy Episode I more than the other groups.The amount of movies seen correlates with the rating for both fans and non fans, but is a stronger correlation with non fans.   Star Trek Fans and Star Wars movies seen and rank<jupyter_code>fig = plt.figure(figsize=(20, 12))
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)
ax4 = fig.add_subplot(2, 2, 4)
star_trek_fan_seen_sum.plot(kind='bar', ax=ax1, title='Star Trek Fan Sum')
not_star_trek_fan_seen_sum.plot(kind='bar', ax=ax2, title='Non Star Trek Fan Sum')
star_trek_fan_rank_mean.plot(kind='bar', ax=ax3, title='Star Trek Fan Rank')
not_star_trek_fan_rank_mean.plot(kind='bar', ax=ax4, title='Non Star Trek Fan Rank')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11917967238488326, 'fraction_numerical': 0.021024119695601702, 'mean_word_length': 5.948028673835125, 'pattern_counts': {'":': 1, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '560703', 'license': 'MIT', 'n_tokens_mistral': 2880, 'n_tokens_neox': 2778, 'n_words': 815, 'path': 'Basics.ipynb', 'repo_name': '81Jeremiah/Star-Wars-Survey-Project', 'size': '7753'}