Cross Tabulation
pd.crosstab() computes frequency tables to show how often value combinations occur.
Basic Crosstab
Count combinations of values:
Loading Pandas Playground...
Adding Margins
Include row and column totals:
Loading Pandas Playground...
Normalizing Values
Show percentages instead of counts:
Loading Pandas Playground...
Aggregating Values
Apply functions to a third column:
Loading Pandas Playground...
Multiple Values
Crosstab with multiple row or column variables:
Loading Pandas Playground...
Crosstab vs Pivot Table
Compare the two approaches:
Loading Pandas Playground...
Exercise: Basic Crosstab
Loading Exercise...
Exercise: Percentage Crosstab
Loading Exercise...
Key Points
pd.crosstab()creates frequency tables- Counts combinations by default
margins=Trueadds totalsnormalize=for percentages ('all', 'index', 'columns')- Use
values=andaggfunc=to aggregate other data - Simpler than pivot_table for counting
التالي · الدرس 23 من 42
Named Aggregation & Window Patterns
قراءة 2 دقيقة
أنهيت 22 من 42 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

