Kurssisisältö
Pandas: First Steps
Pandas: First Steps
1. Getting Started
Introduction to PandasSeriesTask: Coffee Orders SeriesTask: Barista's Favorites CoffeesAccessing Elements from a SeriesTask: Drink of the HourTask - Signature DrinksTask: Mid-Morning SpecialsTask - Fetching the Mid-Shift DrinksOperations over SeriesTask: Modifying a single elementTask: Modifying the Entire SeriesTask: Modifying Part of a SeriesTask: Processing the Restock of Inventory
2. Basics of Dataframes
What is a DataFrame?Task: Creating a Table of Popular Coffee DrinksTask: Tracking Coffee Bean DeliveriesTask: Weekly Coffee Sales ReportAdding new ColumnsTask: Finding Total Sales Per DrinkTask: Calculating Total Sales RevenueAdding new RowsTask: Adding a New Employee to the Café TeamTask: Adding New Coffee Types to the Café Menu
3. Fetching Data from DataFrames
The `head()` MethodTask: Preview the Coffee MenuThe `tail()` MethodTask: Finding the Most Expensive CoffeesThe `sample()` MethodTask: Randomly Select Customer Orders for Quality CheckExtracting Multiple ColumnsTask: Extracting the Total ProfitTask: Extract Sales Data For AnalysisThe `iloc` PropertyTask: Access Sales Data at Café Pandasia - Part 1Task: Access Sales Data at Café Pandasia - Part 2Task: Access Sales Data at Café Pandasia - Part 3
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
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))
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 3