Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Unique Observations | Aggregate Functions
Introduction to pandas [track]
course content

Contenuti del Corso

Introduction to pandas [track]

Introduction to pandas [track]

1. Basics
2. Reading and Exploring Data
3. Accessing DataFrame Values
4. Aggregate Functions

book
Unique Observations

You can get unique values of particular column by applying the .unique() method. Note, that this is Series method, so it works only for one column of DataFrame. For example, you can get all the cars' fuel types.

1234567
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Unique fuel types print(df.fuelType.unique())
copy

Also you can get the total number of unique values within specific column by applying .nunique() method to the column.

1234567
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Number of unique engine sizes print(df.engineSize.nunique())
copy

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 2

Chieda ad AI

expand
ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

course content

Contenuti del Corso

Introduction to pandas [track]

Introduction to pandas [track]

1. Basics
2. Reading and Exploring Data
3. Accessing DataFrame Values
4. Aggregate Functions

book
Unique Observations

You can get unique values of particular column by applying the .unique() method. Note, that this is Series method, so it works only for one column of DataFrame. For example, you can get all the cars' fuel types.

1234567
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Unique fuel types print(df.fuelType.unique())
copy

Also you can get the total number of unique values within specific column by applying .nunique() method to the column.

1234567
# Importing library import pandas as pd # Reading csv file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/67798cef-5e7c-4fbc-af7d-ae96b4443c0a/audi.csv') # Number of unique engine sizes print(df.engineSize.nunique())
copy

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 4. Capitolo 2
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt