- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz di AI & Machine Learning: Pandas groupby & merge
Most feature engineering in pandas comes down to grouping rows and joining tables. This quiz tests groupby() with sum, size, mean and transform, and how the how argument of merge() changes the number of rows you get back.
Domanda di esempio
Domanda 1 di 10What does this print?
import pandas as pd
sales = pd.DataFrame({"city": ["Hanoi", "Hue", "Hanoi", "Hue", "Da Nang"],
"amount": [10, 5, 20, 15, 8]})
print(sales.groupby("city")["amount"].sum().to_dict())
Mostra la risposta
B. {'Da Nang': 8, 'Hanoi': 30, 'Hue': 20} Each city's amounts are added (Hanoi 10 + 20, Hue 5 + 15) and, by default, the group keys come out sorted alphabetically, so Da Nang is first. Pass sort=False to keep first-seen order.
Cosa copre questo quiz
groupby()withsum(),size()andmean()- Group keys are sorted by default
transform()vs aggregation- Inner, left and outer merges and their row counts
- Overlapping column names and the
_x/_ysuffixes
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.