Split-Apply-Combine erklärt
Das Modell hinter jedem groupby
Split-Apply-Combine erklärt ist eine kostenlose Data Science Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Data Science Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
One Idea, Three Steps
Every groupby follows one rhythm: split the rows into groups, apply a calculation to each, then combine the answers back together. 🔁
Split: Cut by a Key
The split step partitions rows by a key column, so all rows sharing the same value land in the same little group.
groups = df.groupby("city")Apply: Do Work Per Group
In the apply step, the same function runs on each group on its own, never mixing one group with another.
df.groupby("city")["sales"].mean()Combine: Stitch Results
The combine step glues each group result into one tidy output, indexed by the group keys you split on.
groupby Is Lazy
Calling groupby alone does almost nothing; it just remembers the plan. The real work waits until you add an aggregation.
g = df.groupby("city") # no math yetThe Group Key Becomes the Index
After aggregating, your group key moves into the result index, so each unique value labels one output row.
Pick a Column to Aggregate
Select a column after grouping to focus the math. Here you ask for the average sales within each city.
df.groupby("city")["sales"].mean()size Counts Rows Per Group
Use size when you just want how many rows fell into each group, including any missing values.
df.groupby("city").size()Iterating Over Groups
You can loop a groupby to inspect it: each turn hands you the group name and the matching sub-table.
for name, part in df.groupby("city"):
print(name, len(part))Why It Beats Manual Loops
Split-apply-combine replaces slow hand-written loops with one fast, readable line that pandas optimizes for you. ⚡
A Tiny End-to-End Example
This single line splits by region, averages each group, and combines the result, all in one readable expression.
df.groupby("region")["revenue"].mean()Quick Check
Which step actually does the calculation?
Recap: The groupby Rhythm
You learned the heartbeat of grouping: split, apply, combine. Master this rhythm and every aggregation later feels natural. 🎯
Häufig gestellte Fragen
Ist die Lektion „Split-Apply-Combine erklärt“ kostenlos?
Ja — der vollständige Text von „Split-Apply-Combine erklärt“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Data Science Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Data Science Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Split-Apply-Combine erklärt“?
Das Modell hinter jedem groupby Du übst Data Science Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Data Science Academy zu starten?
Keine Vorkenntnisse erforderlich. Data Science Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.
Wie lange dauert die Lektion „Split-Apply-Combine erklärt“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Data Science Academy-Lektion Code schreiben und ausführen?
Ja. Jede Data Science Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Split-Apply-Combine erklärt
- Mehrere Aggregationen mit agg
- Nach mehreren Schlüsseln gruppieren
- transform für gruppenbasierte Merkmale