Top 3-Point Field Goal 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 the top 2% players with most 3P (3-Point Field Goals) scored. Show only player name (Player) and 3-Point Field Goals (3P).

Test Cases

test top 3p scorers - Run Test

def test_top_3p_scorers():
    assert top_3p_scorers.shape == (9, 2) and top_3p_scorers.iloc[4,1] == 3.0

Solution 1

import numpy as np
import pandas as pd

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

top_3p_scorers = df.loc[df['3P'] >= df['3P'].quantile(.98), ['Player', '3P']]
Files associated with this lesson:

nba_data.csv

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