Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer The `tail()` Method | Fetching Data from DataFrames
Pandas: First Steps
course content

Cursusinhoud

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes
3. Fetching Data from DataFrames

book
The `tail()` Method

The tail() method fetches the last few rows from a dataframe.

It also returns 5 rows by default. A custom number of rows can be specified using the n named parameter.

Syntax

js

Example

12345678910111213141516171819
import pandas as pd # Create a simple DataFrame about a bookstore books = pd.DataFrame({ 'Title': [ 'The Alchemist', '1984', 'To Kill a Mockingbird', 'The Great Gatsby', 'Moby Dick', 'Pride and Prejudice', 'War and Peace', 'The Hobbit', 'Crime and Punishment', 'Jane Eyre' ], 'Author': [ 'Paulo Coelho', 'George Orwell', 'Harper Lee', 'F. Scott Fitzgerald', 'Herman Melville', 'Jane Austen', 'Leo Tolstoy', 'J.R.R. Tolkien', 'Fyodor Dostoevsky', 'Charlotte Brontë' ], 'Stock': [12, 8, 15, 7, 3, 10, 5, 9, 4, 6] }) print('Show the last 7 books in the list:') print(books.tail(n=3))
copy
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 3

Vraag AI

expand
ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

course content

Cursusinhoud

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes
3. Fetching Data from DataFrames

book
The `tail()` Method

The tail() method fetches the last few rows from a dataframe.

It also returns 5 rows by default. A custom number of rows can be specified using the n named parameter.

Syntax

js

Example

12345678910111213141516171819
import pandas as pd # Create a simple DataFrame about a bookstore books = pd.DataFrame({ 'Title': [ 'The Alchemist', '1984', 'To Kill a Mockingbird', 'The Great Gatsby', 'Moby Dick', 'Pride and Prejudice', 'War and Peace', 'The Hobbit', 'Crime and Punishment', 'Jane Eyre' ], 'Author': [ 'Paulo Coelho', 'George Orwell', 'Harper Lee', 'F. Scott Fitzgerald', 'Herman Melville', 'Jane Austen', 'Leo Tolstoy', 'J.R.R. Tolkien', 'Fyodor Dostoevsky', 'Charlotte Brontë' ], 'Stock': [12, 8, 15, 7, 3, 10, 5, 9, 4, 6] }) print('Show the last 7 books in the list:') print(books.tail(n=3))
copy
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 3
Onze excuses dat er iets mis is gegaan. Wat is er gebeurd?
some-alt