<jupyter_start><jupyter_text>Merging the firstname and lastname column together to give the fullname column<jupyter_code>master["fullName"] = master[["firstName", "lastName"]].apply(lambda a : "{}  {}".format(a[0], a[1]), axis=1)<jupyter_output><empty_output><jupyter_text>Moving the newly created fullname column to the second column<jupyter_code>master = pds.concat([master.iloc[:,0], master.iloc[:,-1], master.iloc[:,1:-1]], axis = 1)
master.birthDate.tail()<jupyter_output><empty_output><jupyter_text>Filling empty birthDate cells with "0000-00-00" so as to classify as unknown<jupyter_code>master.birthDate = master.birthDate.fillna(master.iloc[3713,:].birthDate)
master.head()<jupyter_output><empty_output><jupyter_text>Splitting the birthDate into year, month and day Creating a dataframe with the new columns Merging the new dataframe together with the fullname column Converting the column "year" into "int" datatype<jupyter_code>birth_year = master["birthDate"].str.split('-', expand=True)
birth_year.columns = pds.Series(["year", "month", "day"])

birth_year = pds.concat([master.fullName, birth_year], axis=1)
birth_year.year = birth_year["year"].astype(int)
birth_year.isnull().sum()<jupyter_output><empty_output><jupyter_text>Write a function to group the years into a grouped data with class width "10"<jupyter_code>def classData(iniFrame, uc):
    obtFrame = iniFrame[(iniFrame["year"] < uc)]
    finalFrame = iniFrame.drop(obtFrame.index)
    return obtFrame.year.count(), finalFrame
dummyY = ["ok"]
dummyV = ["ok"]
for i in list(range(0,11)):
    if i == 0:
        iniFrame = birth_year
        accept, finalFrame = classData(iniFrame, 1)
        dummyY.append("unknown")
        dummyV.append(accept)
    else:
        iniFrame = finalFrame
        accept, finalFrame = classData(iniFrame, i*10 + 1900)
        dummyY.append("{} - {}".format((i-1)*10 + 1900, i*10 + 1900 - 1))
        dummyV.append(accept)

col1 = pds.Series(dummyY[1:])
col2 = pds.Series(dummyV[1:])
#np.array.transpose
years = pds.DataFrame({"Years" : col1, "Counts" :col2})
years<jupyter_output><empty_output><jupyter_text>Create a dataframe which consists of players fullname, country of birth and their country of secondary education Replace null values with the most common country of birth and secondary education respectively<jupyter_code>nonemptyBC = master.birthCountry[master.birthCountry.isnull() != True]
nonemptyHSC = master.hsCountry[master.hsCountry.isnull() != True]

master.birthCountry = master.birthCountry.fillna(nonemptyBC.mode()[0])
master.hsCountry = master.hsCountry.fillna(nonemptyHSC.mode()[0])

birthCities = master[["fullName", "birthCountry", "hsCountry"]]
birthCities
plot2 = birthCities.groupby(["birthCountry"])["fullName"].count()
plot2.loc['Others'] = 220
plot2 = plot2.nlargest(8)
plot2
plot3 = birthCities.groupby(["hsCountry"])["fullName"].count()
plot3.loc['Others'] = 58
plot3 = plot3.nlargest(7)
plot3.values<jupyter_output><empty_output><jupyter_text>Filled NA values in column "race" with the most common race: "black" Calculate the percentage of basketball masters that are black or white"<jupyter_code>master.race = master.race.fillna("B")

race = master[["race","fullName"]]

raceT = race.groupby(["race"])["fullName"].count()
raceG = raceT.nlargest(2)
raceG.index = ['Black', 'White']

percentage = np.round((raceG.values)*100/(raceT.sum()),2)
percentage = pds.DataFrame({"Race" : raceG.index, "Percentage" : percentage})
percentage<jupyter_output><empty_output><jupyter_text>End of Data Cleaning Plotting of Charts from the cleaned data<jupyter_code>def plut(plotx, ploty, text):
    fig, ax = plt.subplots(figsize = (9, 5))
    width = np.arange(len(plotx))
    ticks = list(plotx)
    plt.barh(width, ploty, color = ['#091295', '#5c2424', '#0cd48e', '#26512c', '#498593', '#3b1236'])
    plt.yticks(width, ticks)
    plt.title(text, loc ='left', fontdict = {"fontsize": 13, "fontweight" : 'bold', 'color' : 'black'})
    fig.text(0.75, 0.85, 'adaboost', fontsize = 18, color ='#091295',alpha = 0.7)
    plt.show()
#y_year = 
birthYearPlot = plut(years.Years, (years.Counts.values)*0.01, 'PLOT OF PLAYERS\' YEAR OF BIRTH (X100)')
birthCountryplot = plut(plot2.index, np.log(plot2.values), 'LOGARITHMIC PLOT OF PLAYERS\' COUNTRIES OF BIRTH')
hsCountryplot = plut(plot3.index, np.log(plot3.values), 'LOGARITHMIC PLOT OF PLAYERS\' HIGH SCHOOL COUNTRIES')
label = percentage[['Race', 'Percentage']].apply(lambda x : "{} = {}%".format(x[0], x[1]), axis= 1)

plt.pie(raceG, explode = [0.015, 0.015], labels= label.values, labeldistance= 1.1, colors = ['#091295', '#5c2424'], radius = 1.5)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15883236746082852, 'fraction_numerical': 0.0352006868426701, 'mean_word_length': 5.924219910846954, 'pattern_counts': {'":': 1, '<': 34, '<?xml version=': 0, '>': 33, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '515668', 'license': 'MIT', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1635, 'n_words': 361, 'path': 'Adaboost_master_DCV.ipynb', 'repo_name': 'Mariamuwane/AdaBoost', 'size': '4659'}