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
Series
Importing Pandas
Before we can start working with Pandas, we need to import it:
py
Defining a Series
We can define a Series in Pandas using the following syntax:
python
The following code defines a new Series called populations
representing the populations of various cities (in milions):
import pandas as pd populations = pd.Series( [8.9, 3.6, 2.7, 1.6], ["London", "Berlin", "Rome", "Budapest"] ) print(populations)
In some cases you might see the following syntax of creating a Series, which has the same effect, except in this case we use a named parameter to specify the index_list
for the sake of readibility:
py
The index
Property
We can access the list of indices of a Series using the index
property:
import pandas as pd populations = pd.Series( [8.9, 3.6, 2.7, 1.6], ["London", "Berlin", "Rome", "Budapest"] ) print(populations.index)
1. What does the following code create?
2. What will be the output of the following code?
3. You must always specify the index parameter when creating a Series.
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 2