High scorers

For the following exercises, we'll read nba_data.csv CSV file, that contains data of NBA Players (original can be found here).

Your task: Get a list of all the players making more points than the double of the mean. That list should include just players name and points.

Test Cases

test high scorers - Run Test

def test_high_scorers():
    assert high_scorers.shape == (45,2) and high_scorers.iloc[37,1] == 18.3

Solution 1

import numpy as np
import pandas as pd

df = pd.read_csv('nba_data.csv')

high_scorers = df.loc[df['Points'] > 2 * df['Points'].mean(), ['Player', 'Points']]
Files associated with this lesson:

nba_data.csv

import numpy as np import pandas as pd df = pd.read_csv('nba_data.csv') high_scorers = ?