Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære .loc Function | Explore Dataset
Introduction to Python for Data Analysis
course content

Kursinnhold

Introduction to Python for Data Analysis

Introduction to Python for Data Analysis

1. Introduction to Python 1/2
2. Introduction to Python 2/2
3. Explore Dataset
4. Becoming an Analyst

book
.loc Function

Pandas allows you to set specific conditions on the dataset without an if/else statement and loops. Look at the syntax:

  • DataFrame.loc[DataFrame['job_title'] == 'Data Scientist'].count()

So inside the .loc[] function, you just put the condition you need. Here you compare if 'job_title' is equal to 'Data Scientist'.

It compares each value of 'job_title' to the 'Data Scientist' string.

The ways of creating such conditions are the same as for if statements; you can use >, <, >=, =<, == with the same meaning.

question-icon

Here, output data about users that continued the subscription after the trial period (trial is True).

DataFrame = DataFrame.[]
Dataset

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 13

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

Introduction to Python for Data Analysis

Introduction to Python for Data Analysis

1. Introduction to Python 1/2
2. Introduction to Python 2/2
3. Explore Dataset
4. Becoming an Analyst

book
.loc Function

Pandas allows you to set specific conditions on the dataset without an if/else statement and loops. Look at the syntax:

  • DataFrame.loc[DataFrame['job_title'] == 'Data Scientist'].count()

So inside the .loc[] function, you just put the condition you need. Here you compare if 'job_title' is equal to 'Data Scientist'.

It compares each value of 'job_title' to the 'Data Scientist' string.

The ways of creating such conditions are the same as for if statements; you can use >, <, >=, =<, == with the same meaning.

question-icon

Here, output data about users that continued the subscription after the trial period (trial is True).

DataFrame = DataFrame.[]
Dataset

Click or drag`n`drop items and fill in the blanks

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 13
Vi beklager at noe gikk galt. Hva skjedde?
some-alt