<jupyter_start><jupyter_text>* The file ex10_1.txt includes the names of the 20-th NBA players that scored more points* Define a Series with index the name of the players and values the total number of points<jupyter_code>with open("ex10_1.txt","r") as nba:
    lines = nba.readlines()
    scores = pd.Series([int(point.split("\t")[2].replace("\n","")) for point in lines[1:]], index=[point.split("\t")[1] for point in lines[1:]])
print(scores)<jupyter_output><NAME>    38387
<NAME>            36928
<NAME>           34241
<NAME>            33643
<NAME>         32292
<NAME>          31560
<NAME>       31419
<NAME>       28596
<NAME>           27409
<NAME>            27313
<NAME>        26946
<NAME>        26710
<NAME>      26668
<NAME>             26496
<NAME>        26446
<NAME>            26397
<NAME>          26395
<NAME>          26071
<NAME>           25728
Alex English           25613
dtype: int64<jupyter_text>* The file ex10_2.txt includes the names of the 20-th NBA players that played more games* Define a Series with index the name of the players and values the total number of games played<jupyter_code>with open("ex10_2.txt","r") as nba:
    lines = nba.readlines()
    games = pd.Series([int(game.split()[4].replace("\n","")) for game in lines[1:]], index=[point.split("\t")[1] for point in lines[1:]])
print(games)<jupyter_output><empty_output><jupyter_text>* Print the number of points scored by <NAME>an* Print the number of points scored by the 3 top scorers<jupyter_code>print(scores['<NAME>'])
print(scores[:3])<jupyter_output>26496
<NAME>    38387
<NAME>            36928
LeBron James           34241
dtype: int64<jupyter_text>* Define a new series that includes only the players that scored more than 30000 points<jupyter_code>score_more_than = scores[scores > 30000]
print(score_more_than)<jupyter_output><NAME>    38387
<NAME>            36928
LeBron James           34241
<NAME>            33643
<NAME>         32292
<NAME>          31560
Wilt Chamberlain       31419
dtype: int64<jupyter_text>* Remove Dominique Wilkins from the top scoreres<jupyter_code>series_dropped = scores.drop('Dominique Wilkins')
print(series_dropped)<jupyter_output><NAME>    38387
<NAME>            36928
<NAME>           34241
<NAME>            33643
<NAME>         32292
<NAME>          31560
Wilt Chamberlain       31419
<NAME>       28596
<NAME>           27409
<NAME>            27313
<NAME>        26946
<NAME>        26710
<NAME>             26496
<NAME>        26446
<NAME>            26397
<NAME>          26395
<NAME>          26071
<NAME>           25728
<NAME>           25613
dtype: int64<jupyter_text>* Define a new Series equal to the average point per game* Use the method dropna to remove players that are not in one of the two Series* Use the method sort_values to sort the series<jupyter_code>averages = scores / games
print(averages.dropna().sort_values())<jupyter_output><NAME>           16.695652
<NAME>          17.832421
<NAME>             19.034483
<NAME>            19.655249
<NAME>           20.623777
<NAME>          20.735874
<NAME>            20.961627
<NAME>    24.607051
<NAME>            24.994799
<NAME>            25.018970
dtype: float64<jupyter_text>* Merge the series of points and games into a pd.DataFrame<jupyter_code>nba = pd.DataFrame({'games':games,"scores":scores})
nba.index.name = 'Name'
print(nba)<jupyter_output>games   scores
Name                                
<NAME>            NaN  25613.0
<NAME>         1304.0      NaN
<NAME>        1307.0      NaN
<NAME>         NaN  26446.0
<NAME>    1380.0      NaN
<NAME>        1522.0  31560.0
<NAME>       NaN  26668.0
<NAME>          1303.0  27313.0
<NAME>          1335.0      NaN
<NAME>         NaN  26946.0
<NAME>       1327.0      NaN
<NAME>           1391.0      NaN
<NAME>          1410.0      NaN
<NAME>           NaN  26395.0
<NAME>        1504.0      NaN
<NAME>bdul-Jabbar  1560.0  38387.0
<NAME>          1476.0  36928.0
<NAME>        1462.0  26071.0
<NAME>         1424.0      NaN
<NAME>          1346.0  33643.0
Le<NAME>            NaN  34241.0
<NAME>          NaN  32292.0
<NAME>         1329.0  27409.0
<NAME>         NaN  26710.0
<NAME>          1343.0  26397.0
R[...]<jupyter_text>* Add to the dataframe a column with the average points per game using the pd.Series defined above<jupyter_code>nba['average_scores_games'] = averages
print(nba)<jupyter_output>games   scores  average_scores_games
Name                                                      
<NAME>            NaN  25613.0                   NaN
<NAME>         1304.0      NaN                   NaN
<NAME>        1307.0      NaN                   NaN
<NAME>         NaN  26446.0                   NaN
<NAME>    1380.0      NaN                   NaN
<NAME>        1522.0  31560.0             20.735874
<NAME>       NaN  26668.0                   NaN
<NAME>          1303.0  27313.0             20.961627
<NAME>          1335.0      NaN                   NaN
<NAME>         NaN  26946.0                   NaN
<NAME>       1327.0      NaN                   NaN
<NAME>           1391.0      NaN                   NaN
<NAME>          1410.0      NaN                   NaN
<NAME>           NaN  26395.0                   NaN
<NAME>        1504.0      NaN                   N[...]<jupyter_text>* Add to the dataframe the data of the following players:    * <NAME>, points = 23757, games = 1073    * Pau Gasol, points = 20894, games = 1226<jupyter_code>nba = nba.append(pd.DataFrame({
    'scores':{'<NAME>':23757, 'Pau Gasol':20894},
    'games':{'<NAME>':1073, 'Pau Gasol':1226},
}))
print(nba)
nba['average_scores_games'] = nba.scores/nba.games<jupyter_output>games   scores  average_scores_games
<NAME>            NaN  25613.0                   NaN
<NAME>         1304.0      NaN                   NaN
<NAME>        1307.0      NaN                   NaN
<NAME>         NaN  26446.0                   NaN
<NAME>    1380.0      NaN                   NaN
<NAME>        1522.0  31560.0             20.735874
<NAME>       NaN  26668.0                   NaN
<NAME>          1303.0  27313.0             20.961627
<NAME>          1335.0      NaN                   NaN
<NAME>         NaN  26946.0                   NaN
<NAME>       1327.0      NaN                   NaN
<NAME>           1391.0      NaN                   NaN
<NAME>          1410.0      NaN                   NaN
<NAME>           NaN  26395.0                   NaN
<NAME>        1504.0      NaN                   NaN
<NAME>  1560.0  38387.0             24.6070[...]<jupyter_text>* Select only the rows of the dataframe corresponding to players with average number of points per game above 25.0* Select only the rows of the dataframe corresponding to players with average number of points per game above 20.0 and number of games above 1300<jupyter_code>print(nba[nba['average_scores_games'] > 25])
print(nba[(nba.average_scores_games > 20.0) & (nba.games > 1300)])<jupyter_output>games   scores  average_scores_games
<NAME>  1476.0  36928.0              25.01897
                      games   scores  average_scores_games
<NAME>        1522.0  31560.0             20.735874
<NAME>          1303.0  27313.0             20.961627
<NAME>  1560.0  38387.0             24.607051
<NAME>          1476.0  36928.0             25.018970
<NAME>          1346.0  33643.0             24.994799
<NAME>         1329.0  27409.0             20.623777
{'fraction_non_alphanumeric': 0.0966078697421981, 'fraction_numerical': 0.13256445047489823, 'mean_word_length': 1.6590909090909092, 'pattern_counts': {'":': 1, '<': 154, '<?xml version=': 0, '>': 158, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '533279', 'license': 'MIT', 'n_tokens_mistral': 3027, 'n_tokens_neox': 2371, 'n_words': 668, 'path': 'Ex 10/ex10.ipynb', 'repo_name': 'christiandimaio/Programming-For-DataScience', 'size': '8228'}