Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Viewing the Data | Analyzing the Data
Pandas First Steps
course content

Kurssisisältö

Pandas First Steps

Pandas First Steps

1. The Very First Steps
2. Reading Files in Pandas
3. Analyzing the Data

book
Viewing the Data

To view the first few rows of a dataset, we can utilize the head() method. This method accepts an integer as its argument, which specifies the number of rows to display (by default, it shows first 5 rows). Let's take a look at the first 10 rows of our dataset:

python

If we want to see the last few rows of a DataFrame, we can use the tail() method. It works similarly to the head() method:

python

Another useful method for exploring DataFrames is sample(). This method fetches random records from a DataFrame. By default, it retrieves a single random record unless specified otherwise.

python
Tehtävä

Swipe to start coding

You are given a DataFrame named wine_data.

  • Extract the first 10 rows from this DataFrame and store the result in the first_lines variable.
  • Retrieve the last 15 rows from this DataFrame and store the result in the last_lines variable.
  • Select a random sample of 12 rows from this DataFrame and store the result in the random_rows variable.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 1
toggle bottom row

book
Viewing the Data

To view the first few rows of a dataset, we can utilize the head() method. This method accepts an integer as its argument, which specifies the number of rows to display (by default, it shows first 5 rows). Let's take a look at the first 10 rows of our dataset:

python

If we want to see the last few rows of a DataFrame, we can use the tail() method. It works similarly to the head() method:

python

Another useful method for exploring DataFrames is sample(). This method fetches random records from a DataFrame. By default, it retrieves a single random record unless specified otherwise.

python
Tehtävä

Swipe to start coding

You are given a DataFrame named wine_data.

  • Extract the first 10 rows from this DataFrame and store the result in the first_lines variable.
  • Retrieve the last 15 rows from this DataFrame and store the result in the last_lines variable.
  • Select a random sample of 12 rows from this DataFrame and store the result in the random_rows variable.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 1
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt