Jeremiah
Jeremiah

Reputation: 79

Access different values in one data frame column?

Df is a loaded in csv file that contains different stats.

player_name,player_id,season,season_type,team

Giannis Antetokounmpo,antetgi01,2020,PO,MIL

I have tried this:

print(df.loc[(df["team"] == "LAL") & (df["team"] == "LAC") & (df["season_type"] == "

I am trying to access the "team" column and filter elements that also meet the "season_type" requirement, however there is no output.

What works currently:

print(df.loc[(df["team"] == "LAL") & (df["season_type"] == "PO")])

When I do this I am able to get the correct output but for only one specific team. My question is how can I perform this on multiple names?

Upvotes: 1

Views: 44

Answers (1)

Stephen Strosko
Stephen Strosko

Reputation: 665

Good question, this should work for you:

team_list = ["LAL", "LAC"]
df = df[df.team.isin(team_list) & df.season_type == 'PO']

Upvotes: 1

Related Questions