Kursinhalt
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 `iloc` Property
The iloc
property in Pandas allows us to access specific parts of a DataFrame using numerical positions.
You can use iloc
to access:
A single element;
A single row;
A single column;
A range of rows;
A range of columns;
A range of rows and columns.
General Syntax
js
You can also slice:
python
Example
import pandas as pd df = pd.DataFrame({ 'Name': ['Alice', 'Bob', 'Charlie', 'Daisy'], 'Age': [25, 30, 35, 28], 'City': ['New York', 'Paris', 'London', 'Berlin'] }) # Single element print('>> Single Element:\n', df.iloc[1, 2]) # Single row print('\n>> Single Row:\n', df.iloc[2]) # Single column print('\n>> Single Column:\n', df.iloc[:, 1]) # Range of rows print('\n>> Range of Rows:\n', df.iloc[1:3]) # Range of columns print('\n>> Range of Columns:\n', df.iloc[:, 0:2]) # Range of rows and columns print('\n>> Range of Rows & Columns:\n', df.iloc[1:3, 0:2])
War alles klar?
Danke für Ihr Feedback!
Abschnitt 3. Kapitel 10