Contenuti del Corso
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 `head()` Method
The head()
method is used to fetch the first few rows of a DataFrame.
By default, it fetches the first 5
rows, but you can specify how many rows you want using the n
named paramter.
Syntax:
python
Example:
import pandas as pd # Create a simple DataFrame data = { 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eva', 'Frank'], 'Age': [24, 30, 22, 29, 25, 28] } df = pd.DataFrame(data) print('Show the first 5 rows:') print(df.head()) print('Show the first 3 rows:') print(df.head(3))
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 3. Capitolo 1