[{"data":1,"prerenderedAt":6376},["ShallowReactive",2],{"tutorials-pandas":3,"category-items-pandas":387,"content-/pandas/pivot-tables-and-cross-tabulation":388},[4,21,31,40,49,58,67,78,87,96,105,116,125,134,143,154,163,172,181,192,201,210,219,228,239,248,257,266,276,285,294,303,313,322,331,341,350,359,369,378],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":6,"title":8,"description":9,"slug":10,"order":11,"isParent":12,"icon":13,"_type":14,"_id":15,"_source":16,"_file":17,"_stem":18,"_extension":19,"children":20,"expanded":12},"/pandas","",false,"Getting Started","Learn the basics of Pandas, Python's powerful data analysis library for working with spreadsheet-like data","getting-started",1,true,"pi pi-play","markdown","content:pandas:1.index.md","content","pandas/1.index.md","pandas/1.index","md",[21,31,40,49,58],{"_path":22,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":24,"description":25,"slug":26,"parentId":5,"order":27,"_type":14,"_id":28,"_source":16,"_file":29,"_stem":30,"_extension":19},"/pandas/what-is-pandas","pandas","What is Pandas","Understand what Pandas is, why it's essential for data analysis, and how it makes working with data simple and powerful","what-is-pandas",2,"content:pandas:2.what-is-pandas.md","pandas/2.what-is-pandas.md","pandas/2.what-is-pandas",{"_path":32,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":33,"description":34,"slug":35,"parentId":5,"order":36,"_type":14,"_id":37,"_source":16,"_file":38,"_stem":39,"_extension":19},"/pandas/installing-pandas","Installing Pandas","Learn how to install Pandas on your computer and verify it's working properly","installing-pandas",3,"content:pandas:3.installing-pandas.md","pandas/3.installing-pandas.md","pandas/3.installing-pandas",{"_path":41,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":42,"description":43,"slug":44,"parentId":5,"order":45,"_type":14,"_id":46,"_source":16,"_file":47,"_stem":48,"_extension":19},"/pandas/your-first-dataframe","Your First DataFrame","Create your first Pandas DataFrame and learn the basics of working with tabular data","your-first-dataframe",4,"content:pandas:4.your-first-dataframe.md","pandas/4.your-first-dataframe.md","pandas/4.your-first-dataframe",{"_path":50,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":51,"description":52,"slug":53,"parentId":5,"order":54,"_type":14,"_id":55,"_source":16,"_file":56,"_stem":57,"_extension":19},"/pandas/series-vs-dataframe","Series vs DataFrame","Understand the difference between Pandas Series and DataFrames, and learn when to use each one","series-vs-dataframe",5,"content:pandas:5.series-vs-dataframe.md","pandas/5.series-vs-dataframe.md","pandas/5.series-vs-dataframe",{"_path":59,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":60,"description":61,"slug":62,"parentId":5,"order":63,"_type":14,"_id":64,"_source":16,"_file":65,"_stem":66,"_extension":19},"/pandas/basic-dataframe-info","Basic DataFrame Info","Learn how to explore and get basic information about your DataFrames to understand your data","basic-dataframe-info",6,"content:pandas:6.basic-dataframe-info.md","pandas/6.basic-dataframe-info.md","pandas/6.basic-dataframe-info",{"_path":68,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":69,"description":70,"slug":71,"order":72,"isParent":12,"icon":73,"_type":14,"_id":74,"_source":16,"_file":75,"_stem":76,"_extension":19,"children":77,"expanded":12},"/pandas/loading-data","Loading Data","Learn how to load data from various sources into Pandas DataFrames","loading-data",7,"pi pi-download","content:pandas:7.loading-data.md","pandas/7.loading-data.md","pandas/7.loading-data",[78,87,96],{"_path":79,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":80,"description":81,"slug":82,"parentId":68,"order":83,"_type":14,"_id":84,"_source":16,"_file":85,"_stem":86,"_extension":19},"/pandas/reading-files","Reading Files (CSV, Excel, JSON)","Learn how to load data from CSV, Excel, and JSON files into Pandas DataFrames","reading-files",8,"content:pandas:8.reading-files.md","pandas/8.reading-files.md","pandas/8.reading-files",{"_path":88,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":89,"description":90,"slug":91,"parentId":68,"order":92,"_type":14,"_id":93,"_source":16,"_file":94,"_stem":95,"_extension":19},"/pandas/loading-from-databases","Loading from Databases","Learn how to connect to databases and load data directly into Pandas DataFrames","loading-from-databases",9,"content:pandas:9.loading-from-databases.md","pandas/9.loading-from-databases.md","pandas/9.loading-from-databases",{"_path":97,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":98,"description":99,"slug":100,"parentId":68,"order":101,"_type":14,"_id":102,"_source":16,"_file":103,"_stem":104,"_extension":19},"/pandas/handling-file-errors","Handling File Errors","Learn how to handle common errors when loading data files and how to troubleshoot loading problems","handling-file-errors",10,"content:pandas:10.handling-file-errors.md","pandas/10.handling-file-errors.md","pandas/10.handling-file-errors",{"_path":106,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":107,"description":108,"slug":109,"order":110,"isParent":12,"icon":111,"_type":14,"_id":112,"_source":16,"_file":113,"_stem":114,"_extension":19,"children":115,"expanded":12},"/pandas/data-exploration","Data Exploration","Learn how to explore and understand your data using Pandas methods and techniques","data-exploration",11,"pi pi-search","content:pandas:11.data-exploration.md","pandas/11.data-exploration.md","pandas/11.data-exploration",[116,125,134],{"_path":117,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":118,"description":119,"slug":120,"parentId":106,"order":121,"_type":14,"_id":122,"_source":16,"_file":123,"_stem":124,"_extension":19},"/pandas/viewing-your-data","Viewing Your Data","Learn different ways to look at and sample your DataFrame data for exploration and understanding","viewing-your-data",12,"content:pandas:12.viewing-your-data.md","pandas/12.viewing-your-data.md","pandas/12.viewing-your-data",{"_path":126,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":127,"description":128,"slug":129,"parentId":106,"order":130,"_type":14,"_id":131,"_source":16,"_file":132,"_stem":133,"_extension":19},"/pandas/data-shape-and-statistics","Data Shape and Statistics","Learn how to understand your DataFrame's size, structure, and get basic statistical summaries","data-shape-and-statistics",13,"content:pandas:13.data-shape-and-statistics.md","pandas/13.data-shape-and-statistics.md","pandas/13.data-shape-and-statistics",{"_path":135,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":136,"description":137,"slug":138,"parentId":106,"order":139,"_type":14,"_id":140,"_source":16,"_file":141,"_stem":142,"_extension":19},"/pandas/column-information-and-data-types","Column Information and Data Types","Learn how to explore individual columns and understand different data types in your DataFrames","column-information-and-data-types",14,"content:pandas:14.column-information-and-data-types.md","pandas/14.column-information-and-data-types.md","pandas/14.column-information-and-data-types",{"_path":144,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":145,"description":146,"slug":147,"order":148,"isParent":12,"icon":149,"_type":14,"_id":150,"_source":16,"_file":151,"_stem":152,"_extension":19,"children":153,"expanded":12},"/pandas/selecting-data","Selecting Data","Learn how to select specific columns, rows, and subsets of data from your DataFrames","selecting-data",15,"pi pi-filter","content:pandas:15.selecting-data.md","pandas/15.selecting-data.md","pandas/15.selecting-data",[154,163,172],{"_path":155,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":156,"description":157,"slug":158,"parentId":144,"order":159,"_type":14,"_id":160,"_source":16,"_file":161,"_stem":162,"_extension":19},"/pandas/selecting-columns-and-rows","Selecting Columns and Rows","Learn how to select specific columns and rows from your DataFrames using basic selection techniques","selecting-columns-and-rows",16,"content:pandas:16.selecting-columns-and-rows.md","pandas/16.selecting-columns-and-rows.md","pandas/16.selecting-columns-and-rows",{"_path":164,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":165,"description":166,"slug":167,"parentId":144,"order":168,"_type":14,"_id":169,"_source":16,"_file":170,"_stem":171,"_extension":19},"/pandas/using-loc-and-iloc","Using loc and iloc","Master precise data selection with label-based (loc) and position-based (iloc) indexing in pandas","using-loc-and-iloc",17,"content:pandas:17.using-loc-and-iloc.md","pandas/17.using-loc-and-iloc.md","pandas/17.using-loc-and-iloc",{"_path":173,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":174,"description":175,"slug":176,"parentId":144,"order":177,"_type":14,"_id":178,"_source":16,"_file":179,"_stem":180,"_extension":19},"/pandas/boolean-and-conditional-selection","Boolean and Conditional Selection","Learn to filter DataFrames using conditions, boolean logic, and multiple criteria for precise data selection","boolean-and-conditional-selection",18,"content:pandas:18.boolean-and-conditional-selection.md","pandas/18.boolean-and-conditional-selection.md","pandas/18.boolean-and-conditional-selection",{"_path":182,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":183,"description":184,"slug":185,"order":186,"isParent":12,"icon":187,"_type":14,"_id":188,"_source":16,"_file":189,"_stem":190,"_extension":19,"children":191,"expanded":12},"/pandas/data-cleaning","Data Cleaning","Learn essential data cleaning techniques to prepare messy data for analysis","data-cleaning",19,"pi pi-wrench","content:pandas:19.data-cleaning.md","pandas/19.data-cleaning.md","pandas/19.data-cleaning",[192,201,210,219],{"_path":193,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":194,"description":195,"slug":196,"parentId":182,"order":197,"_type":14,"_id":198,"_source":16,"_file":199,"_stem":200,"_extension":19},"/pandas/handling-missing-data","Handling Missing Data","Learn to identify, fill, and remove missing values in your DataFrames effectively","handling-missing-data",20,"content:pandas:20.handling-missing-data.md","pandas/20.handling-missing-data.md","pandas/20.handling-missing-data",{"_path":202,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":203,"description":204,"slug":205,"parentId":182,"order":206,"_type":14,"_id":207,"_source":16,"_file":208,"_stem":209,"_extension":19},"/pandas/removing-duplicates","Removing Duplicates","Learn to find and eliminate duplicate rows from your DataFrames to ensure data quality","removing-duplicates",21,"content:pandas:21.removing-duplicates.md","pandas/21.removing-duplicates.md","pandas/21.removing-duplicates",{"_path":211,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":212,"description":213,"slug":214,"parentId":182,"order":215,"_type":14,"_id":216,"_source":16,"_file":217,"_stem":218,"_extension":19},"/pandas/data-type-conversion","Data Type Conversion","Learn to convert data to the right types for proper analysis and calculations","data-type-conversion",22,"content:pandas:22.data-type-conversion.md","pandas/22.data-type-conversion.md","pandas/22.data-type-conversion",{"_path":220,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":221,"description":222,"slug":223,"parentId":182,"order":224,"_type":14,"_id":225,"_source":16,"_file":226,"_stem":227,"_extension":19},"/pandas/string-cleaning-operations","String Cleaning Operations","Learn to clean and standardize text data for consistent analysis using pandas string methods","string-cleaning-operations",23,"content:pandas:23.string-cleaning-operations.md","pandas/23.string-cleaning-operations.md","pandas/23.string-cleaning-operations",{"_path":229,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":230,"description":231,"slug":232,"order":233,"isParent":12,"icon":234,"_type":14,"_id":235,"_source":16,"_file":236,"_stem":237,"_extension":19,"children":238,"expanded":12},"/pandas/data-transformation","Data Transformation","Learn how to modify, add, and transform data in your DataFrames for analysis","data-transformation",24,"pi pi-folder","content:pandas:24.data-transformation.md","pandas/24.data-transformation.md","pandas/24.data-transformation",[239,248,257],{"_path":240,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":241,"description":242,"slug":243,"parentId":229,"order":244,"_type":14,"_id":245,"_source":16,"_file":246,"_stem":247,"_extension":19},"/pandas/adding-and-modifying-columns","Adding and Modifying Columns","Learn how to create new columns and update existing ones with calculations and conditional logic","adding-and-modifying-columns",25,"content:pandas:25.adding-and-modifying-columns.md","pandas/25.adding-and-modifying-columns.md","pandas/25.adding-and-modifying-columns",{"_path":249,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":250,"description":251,"slug":252,"parentId":229,"order":253,"_type":14,"_id":254,"_source":16,"_file":255,"_stem":256,"_extension":19},"/pandas/applying-functions","Applying Functions","Use built-in and custom functions to transform your data efficiently","applying-functions",26,"content:pandas:26.applying-functions.md","pandas/26.applying-functions.md","pandas/26.applying-functions",{"_path":258,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":259,"description":260,"slug":261,"parentId":229,"order":262,"_type":14,"_id":263,"_source":16,"_file":264,"_stem":265,"_extension":19},"/pandas/renaming-and-sorting-data","Renaming and Sorting Data","Organize your DataFrame with better column names and logical data ordering","renaming-and-sorting-data",27,"content:pandas:27.renaming-and-sorting-data.md","pandas/27.renaming-and-sorting-data.md","pandas/27.renaming-and-sorting-data",{"_path":267,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":268,"description":269,"slug":270,"order":271,"isParent":12,"icon":234,"_type":14,"_id":272,"_source":16,"_file":273,"_stem":274,"_extension":19,"children":275,"expanded":12},"/pandas/grouping-and-aggregation","Grouping and Aggregation","Learn to group data and calculate summary statistics for powerful data analysis","grouping-and-aggregation",28,"content:pandas:28.grouping-and-aggregation.md","pandas/28.grouping-and-aggregation.md","pandas/28.grouping-and-aggregation",[276,285,294],{"_path":277,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":278,"description":279,"slug":280,"parentId":267,"order":281,"_type":14,"_id":282,"_source":16,"_file":283,"_stem":284,"_extension":19},"/pandas/groupby-operations","GroupBy Operations","Learn the fundamentals of splitting data into groups and basic aggregations","groupby-operations",29,"content:pandas:29.groupby-operations.md","pandas/29.groupby-operations.md","pandas/29.groupby-operations",{"_path":286,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":287,"description":288,"slug":289,"parentId":267,"order":290,"_type":14,"_id":291,"_source":16,"_file":292,"_stem":293,"_extension":19},"/pandas/aggregation-functions","Aggregation Functions","Explore different ways to summarize your grouped data with built-in and custom functions","aggregation-functions",30,"content:pandas:30.aggregation-functions.md","pandas/30.aggregation-functions.md","pandas/30.aggregation-functions",{"_path":295,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":296,"description":297,"slug":298,"parentId":267,"order":299,"_type":14,"_id":300,"_source":16,"_file":301,"_stem":302,"_extension":19},"/pandas/pivot-tables-and-cross-tabulation","Pivot Tables and Cross Tabulation","Create powerful summary tables and cross-tabulations for analysis","pivot-tables-and-cross-tabulation",31,"content:pandas:31.pivot-tables-and-cross-tabulation.md","pandas/31.pivot-tables-and-cross-tabulation.md","pandas/31.pivot-tables-and-cross-tabulation",{"_path":304,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":305,"description":306,"slug":307,"order":308,"isParent":12,"icon":234,"_type":14,"_id":309,"_source":16,"_file":310,"_stem":311,"_extension":19,"children":312},"/pandas/combining-data","Combining Data","Learn to combine data from multiple DataFrames for comprehensive analysis","combining-data",32,"content:pandas:32.combining-data.md","pandas/32.combining-data.md","pandas/32.combining-data",[313,322],{"_path":314,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":315,"description":316,"slug":317,"parentId":304,"order":318,"_type":14,"_id":319,"_source":16,"_file":320,"_stem":321,"_extension":19},"/pandas/concatenating-dataframes","Concatenating DataFrames","Learn to stack DataFrames vertically and horizontally for simple data combination","concatenating-dataframes",33,"content:pandas:33.concatenating-dataframes.md","pandas/33.concatenating-dataframes.md","pandas/33.concatenating-dataframes",{"_path":323,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":324,"description":325,"slug":326,"parentId":304,"order":327,"_type":14,"_id":328,"_source":16,"_file":329,"_stem":330,"_extension":19},"/pandas/merging-and-join-operations","Merging and Join Operations","Master different types of joins to combine related data from multiple sources","merging-and-join-operations",34,"content:pandas:34.merging-and-join-operations.md","pandas/34.merging-and-join-operations.md","pandas/34.merging-and-join-operations",{"_path":332,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":333,"description":334,"slug":335,"order":336,"isParent":12,"icon":234,"_type":14,"_id":337,"_source":16,"_file":338,"_stem":339,"_extension":19,"children":340},"/pandas/working-with-dates","Working with Dates","Master date and time operations for time-based analysis and reporting","working-with-dates",35,"content:pandas:35.working-with-dates.md","pandas/35.working-with-dates.md","pandas/35.working-with-dates",[341,350],{"_path":342,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":343,"description":344,"slug":345,"parentId":332,"order":346,"_type":14,"_id":347,"_source":16,"_file":348,"_stem":349,"_extension":19},"/pandas/datetime-operations","DateTime Operations","Learn to convert, manipulate, and extract information from dates and times","datetime-operations",36,"content:pandas:36.datetime-operations.md","pandas/36.datetime-operations.md","pandas/36.datetime-operations",{"_path":351,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":352,"description":353,"slug":354,"parentId":332,"order":355,"_type":14,"_id":356,"_source":16,"_file":357,"_stem":358,"_extension":19},"/pandas/time-series-and-resampling","Time Series and Resampling","Discover how to analyze data over time periods and aggregate by different time intervals","time-series-and-resampling",37,"content:pandas:37.time-series-and-resampling.md","pandas/37.time-series-and-resampling.md","pandas/37.time-series-and-resampling",{"_path":360,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":361,"description":362,"slug":363,"order":364,"isParent":12,"icon":234,"_type":14,"_id":365,"_source":16,"_file":366,"_stem":367,"_extension":19,"children":368},"/pandas/saving-your-work","Saving Your Work","Learn to export your analyzed data to different formats for sharing and reporting","saving-your-work",38,"content:pandas:38.saving-your-work.md","pandas/38.saving-your-work.md","pandas/38.saving-your-work",[369,378],{"_path":370,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":371,"description":372,"slug":373,"parentId":360,"order":374,"_type":14,"_id":375,"_source":16,"_file":376,"_stem":377,"_extension":19},"/pandas/exporting-data","Exporting Data (CSV, Excel, JSON)","Learn to save your DataFrames to common file formats for sharing and reporting","exporting-data",39,"content:pandas:39.exporting-data.md","pandas/39.exporting-data.md","pandas/39.exporting-data",{"_path":379,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":380,"description":381,"slug":382,"parentId":360,"order":383,"_type":14,"_id":384,"_source":16,"_file":385,"_stem":386,"_extension":19},"/pandas/database-export","Database Export","Discover how to save data back to databases for integration with other systems","database-export",40,"content:pandas:40.database-export.md","pandas/40.database-export.md","pandas/40.database-export",[294],{"_path":295,"_dir":23,"_draft":7,"_partial":7,"_locale":6,"title":296,"description":297,"slug":298,"parentId":267,"order":299,"body":389,"_type":14,"_id":300,"_source":16,"_file":301,"_stem":302,"_extension":19},{"type":390,"children":391,"toc":6360},"root",[392,400,406,411,961,968,973,1081,1087,1092,1547,1554,2158,2164,2169,2254,2811,2817,3426,3432,3437,4048,4054,4059,4564,4570,4575,4683,5302,5308,5427,5433,5438,6149,6155,6323,6329,6334,6349,6354],{"type":393,"tag":394,"props":395,"children":396},"element","h1",{"id":298},[397],{"type":398,"value":399},"text","📋 Pivot Tables and Cross Tabulation",{"type":393,"tag":401,"props":402,"children":403},"p",{},[404],{"type":398,"value":405},"Pivot tables and cross-tabulation are incredibly powerful tools for creating summary tables! They help you reorganize and summarize data in ways that reveal patterns and relationships. If you've used Excel pivot tables, pandas makes them even more powerful and flexible.",{"type":393,"tag":401,"props":407,"children":408},{},[409],{"type":398,"value":410},"Think of pivot tables like reorganizing your data to answer specific questions - instead of looking at individual rows, you create a summary table that shows the big picture.",{"type":393,"tag":412,"props":413,"children":414},"code-try",{},[415],{"type":393,"tag":416,"props":417,"children":421},"pre",{"code":418,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Sales data\nsales = pd.DataFrame({\n    'region': ['North', 'South', 'North', 'South', 'North', 'South'],\n    'product': ['Laptop', 'Laptop', 'Mouse', 'Mouse', 'Laptop', 'Mouse'],\n    'quarter': ['Q1', 'Q1', 'Q1', 'Q1', 'Q2', 'Q2'],\n    'revenue': [50000, 75000, 5000, 6000, 60000, 5500]\n})\n\nprint(\"Sales data:\")\nprint(sales)\nprint()\n\n# Create a pivot table\npivot = sales.pivot_table(\n    values='revenue',\n    index='region',\n    columns='product',\n    aggfunc='sum'\n)\nprint(\"Revenue by region and product:\")\nprint(pivot)\n","python","language-python shiki shiki-themes github-light github-dark",[422],{"type":393,"tag":423,"props":424,"children":425},"code",{"__ignoreMap":6},[426,453,461,470,488,554,616,678,746,754,761,784,796,808,815,823,840,863,884,905,922,929,949],{"type":393,"tag":427,"props":428,"children":430},"span",{"class":429,"line":11},"line",[431,437,443,448],{"type":393,"tag":427,"props":432,"children":434},{"style":433},"--shiki-default:#D73A49;--shiki-app-dark-mode:#F97583",[435],{"type":398,"value":436},"import",{"type":393,"tag":427,"props":438,"children":440},{"style":439},"--shiki-default:#24292E;--shiki-app-dark-mode:#E1E4E8",[441],{"type":398,"value":442}," pandas ",{"type":393,"tag":427,"props":444,"children":445},{"style":433},[446],{"type":398,"value":447},"as",{"type":393,"tag":427,"props":449,"children":450},{"style":439},[451],{"type":398,"value":452}," pd\n",{"type":393,"tag":427,"props":454,"children":455},{"class":429,"line":27},[456],{"type":393,"tag":427,"props":457,"children":458},{"emptyLinePlaceholder":12},[459],{"type":398,"value":460},"\n",{"type":393,"tag":427,"props":462,"children":463},{"class":429,"line":36},[464],{"type":393,"tag":427,"props":465,"children":467},{"style":466},"--shiki-default:#6A737D;--shiki-app-dark-mode:#6A737D",[468],{"type":398,"value":469},"# Sales data\n",{"type":393,"tag":427,"props":471,"children":472},{"class":429,"line":45},[473,478,483],{"type":393,"tag":427,"props":474,"children":475},{"style":439},[476],{"type":398,"value":477},"sales ",{"type":393,"tag":427,"props":479,"children":480},{"style":433},[481],{"type":398,"value":482},"=",{"type":393,"tag":427,"props":484,"children":485},{"style":439},[486],{"type":398,"value":487}," pd.DataFrame({\n",{"type":393,"tag":427,"props":489,"children":490},{"class":429,"line":54},[491,497,502,507,512,517,521,525,529,533,537,541,545,549],{"type":393,"tag":427,"props":492,"children":494},{"style":493},"--shiki-default:#032F62;--shiki-app-dark-mode:#9ECBFF",[495],{"type":398,"value":496},"    'region'",{"type":393,"tag":427,"props":498,"children":499},{"style":439},[500],{"type":398,"value":501},": [",{"type":393,"tag":427,"props":503,"children":504},{"style":493},[505],{"type":398,"value":506},"'North'",{"type":393,"tag":427,"props":508,"children":509},{"style":439},[510],{"type":398,"value":511},", ",{"type":393,"tag":427,"props":513,"children":514},{"style":493},[515],{"type":398,"value":516},"'South'",{"type":393,"tag":427,"props":518,"children":519},{"style":439},[520],{"type":398,"value":511},{"type":393,"tag":427,"props":522,"children":523},{"style":493},[524],{"type":398,"value":506},{"type":393,"tag":427,"props":526,"children":527},{"style":439},[528],{"type":398,"value":511},{"type":393,"tag":427,"props":530,"children":531},{"style":493},[532],{"type":398,"value":516},{"type":393,"tag":427,"props":534,"children":535},{"style":439},[536],{"type":398,"value":511},{"type":393,"tag":427,"props":538,"children":539},{"style":493},[540],{"type":398,"value":506},{"type":393,"tag":427,"props":542,"children":543},{"style":439},[544],{"type":398,"value":511},{"type":393,"tag":427,"props":546,"children":547},{"style":493},[548],{"type":398,"value":516},{"type":393,"tag":427,"props":550,"children":551},{"style":439},[552],{"type":398,"value":553},"],\n",{"type":393,"tag":427,"props":555,"children":556},{"class":429,"line":63},[557,562,566,571,575,579,583,588,592,596,600,604,608,612],{"type":393,"tag":427,"props":558,"children":559},{"style":493},[560],{"type":398,"value":561},"    'product'",{"type":393,"tag":427,"props":563,"children":564},{"style":439},[565],{"type":398,"value":501},{"type":393,"tag":427,"props":567,"children":568},{"style":493},[569],{"type":398,"value":570},"'Laptop'",{"type":393,"tag":427,"props":572,"children":573},{"style":439},[574],{"type":398,"value":511},{"type":393,"tag":427,"props":576,"children":577},{"style":493},[578],{"type":398,"value":570},{"type":393,"tag":427,"props":580,"children":581},{"style":439},[582],{"type":398,"value":511},{"type":393,"tag":427,"props":584,"children":585},{"style":493},[586],{"type":398,"value":587},"'Mouse'",{"type":393,"tag":427,"props":589,"children":590},{"style":439},[591],{"type":398,"value":511},{"type":393,"tag":427,"props":593,"children":594},{"style":493},[595],{"type":398,"value":587},{"type":393,"tag":427,"props":597,"children":598},{"style":439},[599],{"type":398,"value":511},{"type":393,"tag":427,"props":601,"children":602},{"style":493},[603],{"type":398,"value":570},{"type":393,"tag":427,"props":605,"children":606},{"style":439},[607],{"type":398,"value":511},{"type":393,"tag":427,"props":609,"children":610},{"style":493},[611],{"type":398,"value":587},{"type":393,"tag":427,"props":613,"children":614},{"style":439},[615],{"type":398,"value":553},{"type":393,"tag":427,"props":617,"children":618},{"class":429,"line":72},[619,624,628,633,637,641,645,649,653,657,661,666,670,674],{"type":393,"tag":427,"props":620,"children":621},{"style":493},[622],{"type":398,"value":623},"    'quarter'",{"type":393,"tag":427,"props":625,"children":626},{"style":439},[627],{"type":398,"value":501},{"type":393,"tag":427,"props":629,"children":630},{"style":493},[631],{"type":398,"value":632},"'Q1'",{"type":393,"tag":427,"props":634,"children":635},{"style":439},[636],{"type":398,"value":511},{"type":393,"tag":427,"props":638,"children":639},{"style":493},[640],{"type":398,"value":632},{"type":393,"tag":427,"props":642,"children":643},{"style":439},[644],{"type":398,"value":511},{"type":393,"tag":427,"props":646,"children":647},{"style":493},[648],{"type":398,"value":632},{"type":393,"tag":427,"props":650,"children":651},{"style":439},[652],{"type":398,"value":511},{"type":393,"tag":427,"props":654,"children":655},{"style":493},[656],{"type":398,"value":632},{"type":393,"tag":427,"props":658,"children":659},{"style":439},[660],{"type":398,"value":511},{"type":393,"tag":427,"props":662,"children":663},{"style":493},[664],{"type":398,"value":665},"'Q2'",{"type":393,"tag":427,"props":667,"children":668},{"style":439},[669],{"type":398,"value":511},{"type":393,"tag":427,"props":671,"children":672},{"style":493},[673],{"type":398,"value":665},{"type":393,"tag":427,"props":675,"children":676},{"style":439},[677],{"type":398,"value":553},{"type":393,"tag":427,"props":679,"children":680},{"class":429,"line":83},[681,686,690,696,700,705,709,714,718,723,727,732,736,741],{"type":393,"tag":427,"props":682,"children":683},{"style":493},[684],{"type":398,"value":685},"    'revenue'",{"type":393,"tag":427,"props":687,"children":688},{"style":439},[689],{"type":398,"value":501},{"type":393,"tag":427,"props":691,"children":693},{"style":692},"--shiki-default:#005CC5;--shiki-app-dark-mode:#79B8FF",[694],{"type":398,"value":695},"50000",{"type":393,"tag":427,"props":697,"children":698},{"style":439},[699],{"type":398,"value":511},{"type":393,"tag":427,"props":701,"children":702},{"style":692},[703],{"type":398,"value":704},"75000",{"type":393,"tag":427,"props":706,"children":707},{"style":439},[708],{"type":398,"value":511},{"type":393,"tag":427,"props":710,"children":711},{"style":692},[712],{"type":398,"value":713},"5000",{"type":393,"tag":427,"props":715,"children":716},{"style":439},[717],{"type":398,"value":511},{"type":393,"tag":427,"props":719,"children":720},{"style":692},[721],{"type":398,"value":722},"6000",{"type":393,"tag":427,"props":724,"children":725},{"style":439},[726],{"type":398,"value":511},{"type":393,"tag":427,"props":728,"children":729},{"style":692},[730],{"type":398,"value":731},"60000",{"type":393,"tag":427,"props":733,"children":734},{"style":439},[735],{"type":398,"value":511},{"type":393,"tag":427,"props":737,"children":738},{"style":692},[739],{"type":398,"value":740},"5500",{"type":393,"tag":427,"props":742,"children":743},{"style":439},[744],{"type":398,"value":745},"]\n",{"type":393,"tag":427,"props":747,"children":748},{"class":429,"line":92},[749],{"type":393,"tag":427,"props":750,"children":751},{"style":439},[752],{"type":398,"value":753},"})\n",{"type":393,"tag":427,"props":755,"children":756},{"class":429,"line":101},[757],{"type":393,"tag":427,"props":758,"children":759},{"emptyLinePlaceholder":12},[760],{"type":398,"value":460},{"type":393,"tag":427,"props":762,"children":763},{"class":429,"line":110},[764,769,774,779],{"type":393,"tag":427,"props":765,"children":766},{"style":692},[767],{"type":398,"value":768},"print",{"type":393,"tag":427,"props":770,"children":771},{"style":439},[772],{"type":398,"value":773},"(",{"type":393,"tag":427,"props":775,"children":776},{"style":493},[777],{"type":398,"value":778},"\"Sales data:\"",{"type":393,"tag":427,"props":780,"children":781},{"style":439},[782],{"type":398,"value":783},")\n",{"type":393,"tag":427,"props":785,"children":786},{"class":429,"line":121},[787,791],{"type":393,"tag":427,"props":788,"children":789},{"style":692},[790],{"type":398,"value":768},{"type":393,"tag":427,"props":792,"children":793},{"style":439},[794],{"type":398,"value":795},"(sales)\n",{"type":393,"tag":427,"props":797,"children":798},{"class":429,"line":130},[799,803],{"type":393,"tag":427,"props":800,"children":801},{"style":692},[802],{"type":398,"value":768},{"type":393,"tag":427,"props":804,"children":805},{"style":439},[806],{"type":398,"value":807},"()\n",{"type":393,"tag":427,"props":809,"children":810},{"class":429,"line":139},[811],{"type":393,"tag":427,"props":812,"children":813},{"emptyLinePlaceholder":12},[814],{"type":398,"value":460},{"type":393,"tag":427,"props":816,"children":817},{"class":429,"line":148},[818],{"type":393,"tag":427,"props":819,"children":820},{"style":466},[821],{"type":398,"value":822},"# Create a pivot table\n",{"type":393,"tag":427,"props":824,"children":825},{"class":429,"line":159},[826,831,835],{"type":393,"tag":427,"props":827,"children":828},{"style":439},[829],{"type":398,"value":830},"pivot ",{"type":393,"tag":427,"props":832,"children":833},{"style":433},[834],{"type":398,"value":482},{"type":393,"tag":427,"props":836,"children":837},{"style":439},[838],{"type":398,"value":839}," sales.pivot_table(\n",{"type":393,"tag":427,"props":841,"children":842},{"class":429,"line":168},[843,849,853,858],{"type":393,"tag":427,"props":844,"children":846},{"style":845},"--shiki-default:#E36209;--shiki-app-dark-mode:#FFAB70",[847],{"type":398,"value":848},"    values",{"type":393,"tag":427,"props":850,"children":851},{"style":433},[852],{"type":398,"value":482},{"type":393,"tag":427,"props":854,"children":855},{"style":493},[856],{"type":398,"value":857},"'revenue'",{"type":393,"tag":427,"props":859,"children":860},{"style":439},[861],{"type":398,"value":862},",\n",{"type":393,"tag":427,"props":864,"children":865},{"class":429,"line":177},[866,871,875,880],{"type":393,"tag":427,"props":867,"children":868},{"style":845},[869],{"type":398,"value":870},"    index",{"type":393,"tag":427,"props":872,"children":873},{"style":433},[874],{"type":398,"value":482},{"type":393,"tag":427,"props":876,"children":877},{"style":493},[878],{"type":398,"value":879},"'region'",{"type":393,"tag":427,"props":881,"children":882},{"style":439},[883],{"type":398,"value":862},{"type":393,"tag":427,"props":885,"children":886},{"class":429,"line":186},[887,892,896,901],{"type":393,"tag":427,"props":888,"children":889},{"style":845},[890],{"type":398,"value":891},"    columns",{"type":393,"tag":427,"props":893,"children":894},{"style":433},[895],{"type":398,"value":482},{"type":393,"tag":427,"props":897,"children":898},{"style":493},[899],{"type":398,"value":900},"'product'",{"type":393,"tag":427,"props":902,"children":903},{"style":439},[904],{"type":398,"value":862},{"type":393,"tag":427,"props":906,"children":907},{"class":429,"line":197},[908,913,917],{"type":393,"tag":427,"props":909,"children":910},{"style":845},[911],{"type":398,"value":912},"    aggfunc",{"type":393,"tag":427,"props":914,"children":915},{"style":433},[916],{"type":398,"value":482},{"type":393,"tag":427,"props":918,"children":919},{"style":493},[920],{"type":398,"value":921},"'sum'\n",{"type":393,"tag":427,"props":923,"children":924},{"class":429,"line":206},[925],{"type":393,"tag":427,"props":926,"children":927},{"style":439},[928],{"type":398,"value":783},{"type":393,"tag":427,"props":930,"children":931},{"class":429,"line":215},[932,936,940,945],{"type":393,"tag":427,"props":933,"children":934},{"style":692},[935],{"type":398,"value":768},{"type":393,"tag":427,"props":937,"children":938},{"style":439},[939],{"type":398,"value":773},{"type":393,"tag":427,"props":941,"children":942},{"style":493},[943],{"type":398,"value":944},"\"Revenue by region and product:\"",{"type":393,"tag":427,"props":946,"children":947},{"style":439},[948],{"type":398,"value":783},{"type":393,"tag":427,"props":950,"children":951},{"class":429,"line":224},[952,956],{"type":393,"tag":427,"props":953,"children":954},{"style":692},[955],{"type":398,"value":768},{"type":393,"tag":427,"props":957,"children":958},{"style":439},[959],{"type":398,"value":960},"(pivot)\n",{"type":393,"tag":962,"props":963,"children":965},"h2",{"id":964},"understanding-pivot-tables",[966],{"type":398,"value":967},"🎯 Understanding Pivot Tables",{"type":393,"tag":401,"props":969,"children":970},{},[971],{"type":398,"value":972},"Pivot tables reorganize your data into a cross-tabular format, making comparisons easy:",{"type":393,"tag":974,"props":975,"children":979},"info-box",{"emoji":976,"title":977,"type":978},"📊","Pivot Table Components","info",[980,989,1034,1042,1050,1058],{"type":393,"tag":401,"props":981,"children":982},{},[983],{"type":393,"tag":984,"props":985,"children":986},"strong",{},[987],{"type":398,"value":988},"Key Components:",{"type":393,"tag":990,"props":991,"children":992},"ul",{},[993,1004,1014,1024],{"type":393,"tag":994,"props":995,"children":996},"li",{},[997,1002],{"type":393,"tag":984,"props":998,"children":999},{},[1000],{"type":398,"value":1001},"Index",{"type":398,"value":1003},": Rows of the pivot table (what you group by)",{"type":393,"tag":994,"props":1005,"children":1006},{},[1007,1012],{"type":393,"tag":984,"props":1008,"children":1009},{},[1010],{"type":398,"value":1011},"Columns",{"type":398,"value":1013},": Columns of the pivot table (categories across the top)",{"type":393,"tag":994,"props":1015,"children":1016},{},[1017,1022],{"type":393,"tag":984,"props":1018,"children":1019},{},[1020],{"type":398,"value":1021},"Values",{"type":398,"value":1023},": What you're measuring/aggregating",{"type":393,"tag":994,"props":1025,"children":1026},{},[1027,1032],{"type":393,"tag":984,"props":1028,"children":1029},{},[1030],{"type":398,"value":1031},"Aggfunc",{"type":398,"value":1033},": How to combine values (sum, mean, count, etc.)",{"type":393,"tag":401,"props":1035,"children":1036},{},[1037],{"type":393,"tag":984,"props":1038,"children":1039},{},[1040],{"type":398,"value":1041},"Example Structure:",{"type":393,"tag":416,"props":1043,"children":1045},{"code":1044},"         Product A    Product B    Product C\nRegion North    1000         500         750\nRegion South     800         600         900\n",[1046],{"type":393,"tag":423,"props":1047,"children":1048},{"__ignoreMap":6},[1049],{"type":398,"value":1044},{"type":393,"tag":401,"props":1051,"children":1052},{},[1053],{"type":393,"tag":984,"props":1054,"children":1055},{},[1056],{"type":398,"value":1057},"Benefits:",{"type":393,"tag":990,"props":1059,"children":1060},{},[1061,1066,1071,1076],{"type":393,"tag":994,"props":1062,"children":1063},{},[1064],{"type":398,"value":1065},"Quick visual comparisons",{"type":393,"tag":994,"props":1067,"children":1068},{},[1069],{"type":398,"value":1070},"Spot patterns and trends",{"type":393,"tag":994,"props":1072,"children":1073},{},[1074],{"type":398,"value":1075},"Create professional summary reports",{"type":393,"tag":994,"props":1077,"children":1078},{},[1079],{"type":398,"value":1080},"Easy to understand format",{"type":393,"tag":962,"props":1082,"children":1084},{"id":1083},"basic-pivot-tables",[1085],{"type":398,"value":1086},"📊 Basic Pivot Tables",{"type":393,"tag":401,"props":1088,"children":1089},{},[1090],{"type":398,"value":1091},"Let's start with simple pivot table examples:",{"type":393,"tag":412,"props":1093,"children":1094},{},[1095],{"type":393,"tag":416,"props":1096,"children":1098},{"code":1097,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Employee data\nemployees = pd.DataFrame({\n    'department': ['Sales', 'IT', 'Sales', 'IT', 'HR', 'HR'],\n    'level': ['Junior', 'Senior', 'Senior', 'Junior', 'Junior', 'Senior'],\n    'salary': [45000, 80000, 65000, 70000, 40000, 55000]\n})\n\nprint(\"Employee data:\")\nprint(employees)\nprint()\n\n# Simple pivot: Average salary by department and level\nsalary_pivot = employees.pivot_table(\n    values='salary',\n    index='department',\n    columns='level',\n    aggfunc='mean'\n)\nprint(\"Average salary by department and level:\")\nprint(salary_pivot)\n",[1099],{"type":393,"tag":423,"props":1100,"children":1101},{"__ignoreMap":6},[1102,1121,1128,1136,1152,1215,1277,1343,1350,1357,1377,1389,1400,1407,1415,1432,1452,1472,1492,1508,1515,1535],{"type":393,"tag":427,"props":1103,"children":1104},{"class":429,"line":11},[1105,1109,1113,1117],{"type":393,"tag":427,"props":1106,"children":1107},{"style":433},[1108],{"type":398,"value":436},{"type":393,"tag":427,"props":1110,"children":1111},{"style":439},[1112],{"type":398,"value":442},{"type":393,"tag":427,"props":1114,"children":1115},{"style":433},[1116],{"type":398,"value":447},{"type":393,"tag":427,"props":1118,"children":1119},{"style":439},[1120],{"type":398,"value":452},{"type":393,"tag":427,"props":1122,"children":1123},{"class":429,"line":27},[1124],{"type":393,"tag":427,"props":1125,"children":1126},{"emptyLinePlaceholder":12},[1127],{"type":398,"value":460},{"type":393,"tag":427,"props":1129,"children":1130},{"class":429,"line":36},[1131],{"type":393,"tag":427,"props":1132,"children":1133},{"style":466},[1134],{"type":398,"value":1135},"# Employee data\n",{"type":393,"tag":427,"props":1137,"children":1138},{"class":429,"line":45},[1139,1144,1148],{"type":393,"tag":427,"props":1140,"children":1141},{"style":439},[1142],{"type":398,"value":1143},"employees ",{"type":393,"tag":427,"props":1145,"children":1146},{"style":433},[1147],{"type":398,"value":482},{"type":393,"tag":427,"props":1149,"children":1150},{"style":439},[1151],{"type":398,"value":487},{"type":393,"tag":427,"props":1153,"children":1154},{"class":429,"line":54},[1155,1160,1164,1169,1173,1178,1182,1186,1190,1194,1198,1203,1207,1211],{"type":393,"tag":427,"props":1156,"children":1157},{"style":493},[1158],{"type":398,"value":1159},"    'department'",{"type":393,"tag":427,"props":1161,"children":1162},{"style":439},[1163],{"type":398,"value":501},{"type":393,"tag":427,"props":1165,"children":1166},{"style":493},[1167],{"type":398,"value":1168},"'Sales'",{"type":393,"tag":427,"props":1170,"children":1171},{"style":439},[1172],{"type":398,"value":511},{"type":393,"tag":427,"props":1174,"children":1175},{"style":493},[1176],{"type":398,"value":1177},"'IT'",{"type":393,"tag":427,"props":1179,"children":1180},{"style":439},[1181],{"type":398,"value":511},{"type":393,"tag":427,"props":1183,"children":1184},{"style":493},[1185],{"type":398,"value":1168},{"type":393,"tag":427,"props":1187,"children":1188},{"style":439},[1189],{"type":398,"value":511},{"type":393,"tag":427,"props":1191,"children":1192},{"style":493},[1193],{"type":398,"value":1177},{"type":393,"tag":427,"props":1195,"children":1196},{"style":439},[1197],{"type":398,"value":511},{"type":393,"tag":427,"props":1199,"children":1200},{"style":493},[1201],{"type":398,"value":1202},"'HR'",{"type":393,"tag":427,"props":1204,"children":1205},{"style":439},[1206],{"type":398,"value":511},{"type":393,"tag":427,"props":1208,"children":1209},{"style":493},[1210],{"type":398,"value":1202},{"type":393,"tag":427,"props":1212,"children":1213},{"style":439},[1214],{"type":398,"value":553},{"type":393,"tag":427,"props":1216,"children":1217},{"class":429,"line":63},[1218,1223,1227,1232,1236,1241,1245,1249,1253,1257,1261,1265,1269,1273],{"type":393,"tag":427,"props":1219,"children":1220},{"style":493},[1221],{"type":398,"value":1222},"    'level'",{"type":393,"tag":427,"props":1224,"children":1225},{"style":439},[1226],{"type":398,"value":501},{"type":393,"tag":427,"props":1228,"children":1229},{"style":493},[1230],{"type":398,"value":1231},"'Junior'",{"type":393,"tag":427,"props":1233,"children":1234},{"style":439},[1235],{"type":398,"value":511},{"type":393,"tag":427,"props":1237,"children":1238},{"style":493},[1239],{"type":398,"value":1240},"'Senior'",{"type":393,"tag":427,"props":1242,"children":1243},{"style":439},[1244],{"type":398,"value":511},{"type":393,"tag":427,"props":1246,"children":1247},{"style":493},[1248],{"type":398,"value":1240},{"type":393,"tag":427,"props":1250,"children":1251},{"style":439},[1252],{"type":398,"value":511},{"type":393,"tag":427,"props":1254,"children":1255},{"style":493},[1256],{"type":398,"value":1231},{"type":393,"tag":427,"props":1258,"children":1259},{"style":439},[1260],{"type":398,"value":511},{"type":393,"tag":427,"props":1262,"children":1263},{"style":493},[1264],{"type":398,"value":1231},{"type":393,"tag":427,"props":1266,"children":1267},{"style":439},[1268],{"type":398,"value":511},{"type":393,"tag":427,"props":1270,"children":1271},{"style":493},[1272],{"type":398,"value":1240},{"type":393,"tag":427,"props":1274,"children":1275},{"style":439},[1276],{"type":398,"value":553},{"type":393,"tag":427,"props":1278,"children":1279},{"class":429,"line":72},[1280,1285,1289,1294,1298,1303,1307,1312,1316,1321,1325,1330,1334,1339],{"type":393,"tag":427,"props":1281,"children":1282},{"style":493},[1283],{"type":398,"value":1284},"    'salary'",{"type":393,"tag":427,"props":1286,"children":1287},{"style":439},[1288],{"type":398,"value":501},{"type":393,"tag":427,"props":1290,"children":1291},{"style":692},[1292],{"type":398,"value":1293},"45000",{"type":393,"tag":427,"props":1295,"children":1296},{"style":439},[1297],{"type":398,"value":511},{"type":393,"tag":427,"props":1299,"children":1300},{"style":692},[1301],{"type":398,"value":1302},"80000",{"type":393,"tag":427,"props":1304,"children":1305},{"style":439},[1306],{"type":398,"value":511},{"type":393,"tag":427,"props":1308,"children":1309},{"style":692},[1310],{"type":398,"value":1311},"65000",{"type":393,"tag":427,"props":1313,"children":1314},{"style":439},[1315],{"type":398,"value":511},{"type":393,"tag":427,"props":1317,"children":1318},{"style":692},[1319],{"type":398,"value":1320},"70000",{"type":393,"tag":427,"props":1322,"children":1323},{"style":439},[1324],{"type":398,"value":511},{"type":393,"tag":427,"props":1326,"children":1327},{"style":692},[1328],{"type":398,"value":1329},"40000",{"type":393,"tag":427,"props":1331,"children":1332},{"style":439},[1333],{"type":398,"value":511},{"type":393,"tag":427,"props":1335,"children":1336},{"style":692},[1337],{"type":398,"value":1338},"55000",{"type":393,"tag":427,"props":1340,"children":1341},{"style":439},[1342],{"type":398,"value":745},{"type":393,"tag":427,"props":1344,"children":1345},{"class":429,"line":83},[1346],{"type":393,"tag":427,"props":1347,"children":1348},{"style":439},[1349],{"type":398,"value":753},{"type":393,"tag":427,"props":1351,"children":1352},{"class":429,"line":92},[1353],{"type":393,"tag":427,"props":1354,"children":1355},{"emptyLinePlaceholder":12},[1356],{"type":398,"value":460},{"type":393,"tag":427,"props":1358,"children":1359},{"class":429,"line":101},[1360,1364,1368,1373],{"type":393,"tag":427,"props":1361,"children":1362},{"style":692},[1363],{"type":398,"value":768},{"type":393,"tag":427,"props":1365,"children":1366},{"style":439},[1367],{"type":398,"value":773},{"type":393,"tag":427,"props":1369,"children":1370},{"style":493},[1371],{"type":398,"value":1372},"\"Employee data:\"",{"type":393,"tag":427,"props":1374,"children":1375},{"style":439},[1376],{"type":398,"value":783},{"type":393,"tag":427,"props":1378,"children":1379},{"class":429,"line":110},[1380,1384],{"type":393,"tag":427,"props":1381,"children":1382},{"style":692},[1383],{"type":398,"value":768},{"type":393,"tag":427,"props":1385,"children":1386},{"style":439},[1387],{"type":398,"value":1388},"(employees)\n",{"type":393,"tag":427,"props":1390,"children":1391},{"class":429,"line":121},[1392,1396],{"type":393,"tag":427,"props":1393,"children":1394},{"style":692},[1395],{"type":398,"value":768},{"type":393,"tag":427,"props":1397,"children":1398},{"style":439},[1399],{"type":398,"value":807},{"type":393,"tag":427,"props":1401,"children":1402},{"class":429,"line":130},[1403],{"type":393,"tag":427,"props":1404,"children":1405},{"emptyLinePlaceholder":12},[1406],{"type":398,"value":460},{"type":393,"tag":427,"props":1408,"children":1409},{"class":429,"line":139},[1410],{"type":393,"tag":427,"props":1411,"children":1412},{"style":466},[1413],{"type":398,"value":1414},"# Simple pivot: Average salary by department and level\n",{"type":393,"tag":427,"props":1416,"children":1417},{"class":429,"line":148},[1418,1423,1427],{"type":393,"tag":427,"props":1419,"children":1420},{"style":439},[1421],{"type":398,"value":1422},"salary_pivot ",{"type":393,"tag":427,"props":1424,"children":1425},{"style":433},[1426],{"type":398,"value":482},{"type":393,"tag":427,"props":1428,"children":1429},{"style":439},[1430],{"type":398,"value":1431}," employees.pivot_table(\n",{"type":393,"tag":427,"props":1433,"children":1434},{"class":429,"line":159},[1435,1439,1443,1448],{"type":393,"tag":427,"props":1436,"children":1437},{"style":845},[1438],{"type":398,"value":848},{"type":393,"tag":427,"props":1440,"children":1441},{"style":433},[1442],{"type":398,"value":482},{"type":393,"tag":427,"props":1444,"children":1445},{"style":493},[1446],{"type":398,"value":1447},"'salary'",{"type":393,"tag":427,"props":1449,"children":1450},{"style":439},[1451],{"type":398,"value":862},{"type":393,"tag":427,"props":1453,"children":1454},{"class":429,"line":168},[1455,1459,1463,1468],{"type":393,"tag":427,"props":1456,"children":1457},{"style":845},[1458],{"type":398,"value":870},{"type":393,"tag":427,"props":1460,"children":1461},{"style":433},[1462],{"type":398,"value":482},{"type":393,"tag":427,"props":1464,"children":1465},{"style":493},[1466],{"type":398,"value":1467},"'department'",{"type":393,"tag":427,"props":1469,"children":1470},{"style":439},[1471],{"type":398,"value":862},{"type":393,"tag":427,"props":1473,"children":1474},{"class":429,"line":177},[1475,1479,1483,1488],{"type":393,"tag":427,"props":1476,"children":1477},{"style":845},[1478],{"type":398,"value":891},{"type":393,"tag":427,"props":1480,"children":1481},{"style":433},[1482],{"type":398,"value":482},{"type":393,"tag":427,"props":1484,"children":1485},{"style":493},[1486],{"type":398,"value":1487},"'level'",{"type":393,"tag":427,"props":1489,"children":1490},{"style":439},[1491],{"type":398,"value":862},{"type":393,"tag":427,"props":1493,"children":1494},{"class":429,"line":186},[1495,1499,1503],{"type":393,"tag":427,"props":1496,"children":1497},{"style":845},[1498],{"type":398,"value":912},{"type":393,"tag":427,"props":1500,"children":1501},{"style":433},[1502],{"type":398,"value":482},{"type":393,"tag":427,"props":1504,"children":1505},{"style":493},[1506],{"type":398,"value":1507},"'mean'\n",{"type":393,"tag":427,"props":1509,"children":1510},{"class":429,"line":197},[1511],{"type":393,"tag":427,"props":1512,"children":1513},{"style":439},[1514],{"type":398,"value":783},{"type":393,"tag":427,"props":1516,"children":1517},{"class":429,"line":206},[1518,1522,1526,1531],{"type":393,"tag":427,"props":1519,"children":1520},{"style":692},[1521],{"type":398,"value":768},{"type":393,"tag":427,"props":1523,"children":1524},{"style":439},[1525],{"type":398,"value":773},{"type":393,"tag":427,"props":1527,"children":1528},{"style":493},[1529],{"type":398,"value":1530},"\"Average salary by department and level:\"",{"type":393,"tag":427,"props":1532,"children":1533},{"style":439},[1534],{"type":398,"value":783},{"type":393,"tag":427,"props":1536,"children":1537},{"class":429,"line":215},[1538,1542],{"type":393,"tag":427,"props":1539,"children":1540},{"style":692},[1541],{"type":398,"value":768},{"type":393,"tag":427,"props":1543,"children":1544},{"style":439},[1545],{"type":398,"value":1546},"(salary_pivot)\n",{"type":393,"tag":1548,"props":1549,"children":1551},"h3",{"id":1550},"different-aggregation-functions",[1552],{"type":398,"value":1553},"Different Aggregation Functions",{"type":393,"tag":412,"props":1555,"children":1556},{},[1557],{"type":393,"tag":416,"props":1558,"children":1560},{"code":1559,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Product reviews\nreviews = pd.DataFrame({\n    'product': ['Laptop', 'Mouse', 'Laptop', 'Keyboard', 'Mouse'],\n    'rating': [5, 4, 4, 5, 3],\n    'price_range': ['High', 'Low', 'High', 'Medium', 'Low']\n})\n\nprint(\"Product reviews:\")\nprint(reviews)\nprint()\n\n# Count of reviews\nreview_count = reviews.pivot_table(\n    values='rating',\n    index='product',\n    columns='price_range',\n    aggfunc='count',\n    fill_value=0  # Replace NaN with 0\n)\nprint(\"Number of reviews by product and price range:\")\nprint(review_count)\nprint()\n\n# Average rating\navg_rating = reviews.pivot_table(\n    values='rating',\n    index='product',\n    columns='price_range',\n    aggfunc='mean'\n)\nprint(\"Average rating by product and price range:\")\nprint(avg_rating)\n",[1561],{"type":393,"tag":423,"props":1562,"children":1563},{"__ignoreMap":6},[1564,1583,1590,1598,1614,1666,1721,1776,1783,1790,1810,1822,1833,1840,1848,1865,1885,1904,1924,1944,1966,1973,1993,2005,2016,2023,2031,2047,2066,2085,2104,2119,2126,2146],{"type":393,"tag":427,"props":1565,"children":1566},{"class":429,"line":11},[1567,1571,1575,1579],{"type":393,"tag":427,"props":1568,"children":1569},{"style":433},[1570],{"type":398,"value":436},{"type":393,"tag":427,"props":1572,"children":1573},{"style":439},[1574],{"type":398,"value":442},{"type":393,"tag":427,"props":1576,"children":1577},{"style":433},[1578],{"type":398,"value":447},{"type":393,"tag":427,"props":1580,"children":1581},{"style":439},[1582],{"type":398,"value":452},{"type":393,"tag":427,"props":1584,"children":1585},{"class":429,"line":27},[1586],{"type":393,"tag":427,"props":1587,"children":1588},{"emptyLinePlaceholder":12},[1589],{"type":398,"value":460},{"type":393,"tag":427,"props":1591,"children":1592},{"class":429,"line":36},[1593],{"type":393,"tag":427,"props":1594,"children":1595},{"style":466},[1596],{"type":398,"value":1597},"# Product reviews\n",{"type":393,"tag":427,"props":1599,"children":1600},{"class":429,"line":45},[1601,1606,1610],{"type":393,"tag":427,"props":1602,"children":1603},{"style":439},[1604],{"type":398,"value":1605},"reviews ",{"type":393,"tag":427,"props":1607,"children":1608},{"style":433},[1609],{"type":398,"value":482},{"type":393,"tag":427,"props":1611,"children":1612},{"style":439},[1613],{"type":398,"value":487},{"type":393,"tag":427,"props":1615,"children":1616},{"class":429,"line":54},[1617,1621,1625,1629,1633,1637,1641,1645,1649,1654,1658,1662],{"type":393,"tag":427,"props":1618,"children":1619},{"style":493},[1620],{"type":398,"value":561},{"type":393,"tag":427,"props":1622,"children":1623},{"style":439},[1624],{"type":398,"value":501},{"type":393,"tag":427,"props":1626,"children":1627},{"style":493},[1628],{"type":398,"value":570},{"type":393,"tag":427,"props":1630,"children":1631},{"style":439},[1632],{"type":398,"value":511},{"type":393,"tag":427,"props":1634,"children":1635},{"style":493},[1636],{"type":398,"value":587},{"type":393,"tag":427,"props":1638,"children":1639},{"style":439},[1640],{"type":398,"value":511},{"type":393,"tag":427,"props":1642,"children":1643},{"style":493},[1644],{"type":398,"value":570},{"type":393,"tag":427,"props":1646,"children":1647},{"style":439},[1648],{"type":398,"value":511},{"type":393,"tag":427,"props":1650,"children":1651},{"style":493},[1652],{"type":398,"value":1653},"'Keyboard'",{"type":393,"tag":427,"props":1655,"children":1656},{"style":439},[1657],{"type":398,"value":511},{"type":393,"tag":427,"props":1659,"children":1660},{"style":493},[1661],{"type":398,"value":587},{"type":393,"tag":427,"props":1663,"children":1664},{"style":439},[1665],{"type":398,"value":553},{"type":393,"tag":427,"props":1667,"children":1668},{"class":429,"line":63},[1669,1674,1678,1683,1687,1692,1696,1700,1704,1708,1712,1717],{"type":393,"tag":427,"props":1670,"children":1671},{"style":493},[1672],{"type":398,"value":1673},"    'rating'",{"type":393,"tag":427,"props":1675,"children":1676},{"style":439},[1677],{"type":398,"value":501},{"type":393,"tag":427,"props":1679,"children":1680},{"style":692},[1681],{"type":398,"value":1682},"5",{"type":393,"tag":427,"props":1684,"children":1685},{"style":439},[1686],{"type":398,"value":511},{"type":393,"tag":427,"props":1688,"children":1689},{"style":692},[1690],{"type":398,"value":1691},"4",{"type":393,"tag":427,"props":1693,"children":1694},{"style":439},[1695],{"type":398,"value":511},{"type":393,"tag":427,"props":1697,"children":1698},{"style":692},[1699],{"type":398,"value":1691},{"type":393,"tag":427,"props":1701,"children":1702},{"style":439},[1703],{"type":398,"value":511},{"type":393,"tag":427,"props":1705,"children":1706},{"style":692},[1707],{"type":398,"value":1682},{"type":393,"tag":427,"props":1709,"children":1710},{"style":439},[1711],{"type":398,"value":511},{"type":393,"tag":427,"props":1713,"children":1714},{"style":692},[1715],{"type":398,"value":1716},"3",{"type":393,"tag":427,"props":1718,"children":1719},{"style":439},[1720],{"type":398,"value":553},{"type":393,"tag":427,"props":1722,"children":1723},{"class":429,"line":72},[1724,1729,1733,1738,1742,1747,1751,1755,1759,1764,1768,1772],{"type":393,"tag":427,"props":1725,"children":1726},{"style":493},[1727],{"type":398,"value":1728},"    'price_range'",{"type":393,"tag":427,"props":1730,"children":1731},{"style":439},[1732],{"type":398,"value":501},{"type":393,"tag":427,"props":1734,"children":1735},{"style":493},[1736],{"type":398,"value":1737},"'High'",{"type":393,"tag":427,"props":1739,"children":1740},{"style":439},[1741],{"type":398,"value":511},{"type":393,"tag":427,"props":1743,"children":1744},{"style":493},[1745],{"type":398,"value":1746},"'Low'",{"type":393,"tag":427,"props":1748,"children":1749},{"style":439},[1750],{"type":398,"value":511},{"type":393,"tag":427,"props":1752,"children":1753},{"style":493},[1754],{"type":398,"value":1737},{"type":393,"tag":427,"props":1756,"children":1757},{"style":439},[1758],{"type":398,"value":511},{"type":393,"tag":427,"props":1760,"children":1761},{"style":493},[1762],{"type":398,"value":1763},"'Medium'",{"type":393,"tag":427,"props":1765,"children":1766},{"style":439},[1767],{"type":398,"value":511},{"type":393,"tag":427,"props":1769,"children":1770},{"style":493},[1771],{"type":398,"value":1746},{"type":393,"tag":427,"props":1773,"children":1774},{"style":439},[1775],{"type":398,"value":745},{"type":393,"tag":427,"props":1777,"children":1778},{"class":429,"line":83},[1779],{"type":393,"tag":427,"props":1780,"children":1781},{"style":439},[1782],{"type":398,"value":753},{"type":393,"tag":427,"props":1784,"children":1785},{"class":429,"line":92},[1786],{"type":393,"tag":427,"props":1787,"children":1788},{"emptyLinePlaceholder":12},[1789],{"type":398,"value":460},{"type":393,"tag":427,"props":1791,"children":1792},{"class":429,"line":101},[1793,1797,1801,1806],{"type":393,"tag":427,"props":1794,"children":1795},{"style":692},[1796],{"type":398,"value":768},{"type":393,"tag":427,"props":1798,"children":1799},{"style":439},[1800],{"type":398,"value":773},{"type":393,"tag":427,"props":1802,"children":1803},{"style":493},[1804],{"type":398,"value":1805},"\"Product reviews:\"",{"type":393,"tag":427,"props":1807,"children":1808},{"style":439},[1809],{"type":398,"value":783},{"type":393,"tag":427,"props":1811,"children":1812},{"class":429,"line":110},[1813,1817],{"type":393,"tag":427,"props":1814,"children":1815},{"style":692},[1816],{"type":398,"value":768},{"type":393,"tag":427,"props":1818,"children":1819},{"style":439},[1820],{"type":398,"value":1821},"(reviews)\n",{"type":393,"tag":427,"props":1823,"children":1824},{"class":429,"line":121},[1825,1829],{"type":393,"tag":427,"props":1826,"children":1827},{"style":692},[1828],{"type":398,"value":768},{"type":393,"tag":427,"props":1830,"children":1831},{"style":439},[1832],{"type":398,"value":807},{"type":393,"tag":427,"props":1834,"children":1835},{"class":429,"line":130},[1836],{"type":393,"tag":427,"props":1837,"children":1838},{"emptyLinePlaceholder":12},[1839],{"type":398,"value":460},{"type":393,"tag":427,"props":1841,"children":1842},{"class":429,"line":139},[1843],{"type":393,"tag":427,"props":1844,"children":1845},{"style":466},[1846],{"type":398,"value":1847},"# Count of reviews\n",{"type":393,"tag":427,"props":1849,"children":1850},{"class":429,"line":148},[1851,1856,1860],{"type":393,"tag":427,"props":1852,"children":1853},{"style":439},[1854],{"type":398,"value":1855},"review_count ",{"type":393,"tag":427,"props":1857,"children":1858},{"style":433},[1859],{"type":398,"value":482},{"type":393,"tag":427,"props":1861,"children":1862},{"style":439},[1863],{"type":398,"value":1864}," reviews.pivot_table(\n",{"type":393,"tag":427,"props":1866,"children":1867},{"class":429,"line":159},[1868,1872,1876,1881],{"type":393,"tag":427,"props":1869,"children":1870},{"style":845},[1871],{"type":398,"value":848},{"type":393,"tag":427,"props":1873,"children":1874},{"style":433},[1875],{"type":398,"value":482},{"type":393,"tag":427,"props":1877,"children":1878},{"style":493},[1879],{"type":398,"value":1880},"'rating'",{"type":393,"tag":427,"props":1882,"children":1883},{"style":439},[1884],{"type":398,"value":862},{"type":393,"tag":427,"props":1886,"children":1887},{"class":429,"line":168},[1888,1892,1896,1900],{"type":393,"tag":427,"props":1889,"children":1890},{"style":845},[1891],{"type":398,"value":870},{"type":393,"tag":427,"props":1893,"children":1894},{"style":433},[1895],{"type":398,"value":482},{"type":393,"tag":427,"props":1897,"children":1898},{"style":493},[1899],{"type":398,"value":900},{"type":393,"tag":427,"props":1901,"children":1902},{"style":439},[1903],{"type":398,"value":862},{"type":393,"tag":427,"props":1905,"children":1906},{"class":429,"line":177},[1907,1911,1915,1920],{"type":393,"tag":427,"props":1908,"children":1909},{"style":845},[1910],{"type":398,"value":891},{"type":393,"tag":427,"props":1912,"children":1913},{"style":433},[1914],{"type":398,"value":482},{"type":393,"tag":427,"props":1916,"children":1917},{"style":493},[1918],{"type":398,"value":1919},"'price_range'",{"type":393,"tag":427,"props":1921,"children":1922},{"style":439},[1923],{"type":398,"value":862},{"type":393,"tag":427,"props":1925,"children":1926},{"class":429,"line":186},[1927,1931,1935,1940],{"type":393,"tag":427,"props":1928,"children":1929},{"style":845},[1930],{"type":398,"value":912},{"type":393,"tag":427,"props":1932,"children":1933},{"style":433},[1934],{"type":398,"value":482},{"type":393,"tag":427,"props":1936,"children":1937},{"style":493},[1938],{"type":398,"value":1939},"'count'",{"type":393,"tag":427,"props":1941,"children":1942},{"style":439},[1943],{"type":398,"value":862},{"type":393,"tag":427,"props":1945,"children":1946},{"class":429,"line":197},[1947,1952,1956,1961],{"type":393,"tag":427,"props":1948,"children":1949},{"style":845},[1950],{"type":398,"value":1951},"    fill_value",{"type":393,"tag":427,"props":1953,"children":1954},{"style":433},[1955],{"type":398,"value":482},{"type":393,"tag":427,"props":1957,"children":1958},{"style":692},[1959],{"type":398,"value":1960},"0",{"type":393,"tag":427,"props":1962,"children":1963},{"style":466},[1964],{"type":398,"value":1965},"  # Replace NaN with 0\n",{"type":393,"tag":427,"props":1967,"children":1968},{"class":429,"line":206},[1969],{"type":393,"tag":427,"props":1970,"children":1971},{"style":439},[1972],{"type":398,"value":783},{"type":393,"tag":427,"props":1974,"children":1975},{"class":429,"line":215},[1976,1980,1984,1989],{"type":393,"tag":427,"props":1977,"children":1978},{"style":692},[1979],{"type":398,"value":768},{"type":393,"tag":427,"props":1981,"children":1982},{"style":439},[1983],{"type":398,"value":773},{"type":393,"tag":427,"props":1985,"children":1986},{"style":493},[1987],{"type":398,"value":1988},"\"Number of reviews by product and price range:\"",{"type":393,"tag":427,"props":1990,"children":1991},{"style":439},[1992],{"type":398,"value":783},{"type":393,"tag":427,"props":1994,"children":1995},{"class":429,"line":224},[1996,2000],{"type":393,"tag":427,"props":1997,"children":1998},{"style":692},[1999],{"type":398,"value":768},{"type":393,"tag":427,"props":2001,"children":2002},{"style":439},[2003],{"type":398,"value":2004},"(review_count)\n",{"type":393,"tag":427,"props":2006,"children":2007},{"class":429,"line":233},[2008,2012],{"type":393,"tag":427,"props":2009,"children":2010},{"style":692},[2011],{"type":398,"value":768},{"type":393,"tag":427,"props":2013,"children":2014},{"style":439},[2015],{"type":398,"value":807},{"type":393,"tag":427,"props":2017,"children":2018},{"class":429,"line":244},[2019],{"type":393,"tag":427,"props":2020,"children":2021},{"emptyLinePlaceholder":12},[2022],{"type":398,"value":460},{"type":393,"tag":427,"props":2024,"children":2025},{"class":429,"line":253},[2026],{"type":393,"tag":427,"props":2027,"children":2028},{"style":466},[2029],{"type":398,"value":2030},"# Average rating\n",{"type":393,"tag":427,"props":2032,"children":2033},{"class":429,"line":262},[2034,2039,2043],{"type":393,"tag":427,"props":2035,"children":2036},{"style":439},[2037],{"type":398,"value":2038},"avg_rating ",{"type":393,"tag":427,"props":2040,"children":2041},{"style":433},[2042],{"type":398,"value":482},{"type":393,"tag":427,"props":2044,"children":2045},{"style":439},[2046],{"type":398,"value":1864},{"type":393,"tag":427,"props":2048,"children":2049},{"class":429,"line":271},[2050,2054,2058,2062],{"type":393,"tag":427,"props":2051,"children":2052},{"style":845},[2053],{"type":398,"value":848},{"type":393,"tag":427,"props":2055,"children":2056},{"style":433},[2057],{"type":398,"value":482},{"type":393,"tag":427,"props":2059,"children":2060},{"style":493},[2061],{"type":398,"value":1880},{"type":393,"tag":427,"props":2063,"children":2064},{"style":439},[2065],{"type":398,"value":862},{"type":393,"tag":427,"props":2067,"children":2068},{"class":429,"line":281},[2069,2073,2077,2081],{"type":393,"tag":427,"props":2070,"children":2071},{"style":845},[2072],{"type":398,"value":870},{"type":393,"tag":427,"props":2074,"children":2075},{"style":433},[2076],{"type":398,"value":482},{"type":393,"tag":427,"props":2078,"children":2079},{"style":493},[2080],{"type":398,"value":900},{"type":393,"tag":427,"props":2082,"children":2083},{"style":439},[2084],{"type":398,"value":862},{"type":393,"tag":427,"props":2086,"children":2087},{"class":429,"line":290},[2088,2092,2096,2100],{"type":393,"tag":427,"props":2089,"children":2090},{"style":845},[2091],{"type":398,"value":891},{"type":393,"tag":427,"props":2093,"children":2094},{"style":433},[2095],{"type":398,"value":482},{"type":393,"tag":427,"props":2097,"children":2098},{"style":493},[2099],{"type":398,"value":1919},{"type":393,"tag":427,"props":2101,"children":2102},{"style":439},[2103],{"type":398,"value":862},{"type":393,"tag":427,"props":2105,"children":2106},{"class":429,"line":299},[2107,2111,2115],{"type":393,"tag":427,"props":2108,"children":2109},{"style":845},[2110],{"type":398,"value":912},{"type":393,"tag":427,"props":2112,"children":2113},{"style":433},[2114],{"type":398,"value":482},{"type":393,"tag":427,"props":2116,"children":2117},{"style":493},[2118],{"type":398,"value":1507},{"type":393,"tag":427,"props":2120,"children":2121},{"class":429,"line":308},[2122],{"type":393,"tag":427,"props":2123,"children":2124},{"style":439},[2125],{"type":398,"value":783},{"type":393,"tag":427,"props":2127,"children":2128},{"class":429,"line":318},[2129,2133,2137,2142],{"type":393,"tag":427,"props":2130,"children":2131},{"style":692},[2132],{"type":398,"value":768},{"type":393,"tag":427,"props":2134,"children":2135},{"style":439},[2136],{"type":398,"value":773},{"type":393,"tag":427,"props":2138,"children":2139},{"style":493},[2140],{"type":398,"value":2141},"\"Average rating by product and price range:\"",{"type":393,"tag":427,"props":2143,"children":2144},{"style":439},[2145],{"type":398,"value":783},{"type":393,"tag":427,"props":2147,"children":2148},{"class":429,"line":327},[2149,2153],{"type":393,"tag":427,"props":2150,"children":2151},{"style":692},[2152],{"type":398,"value":768},{"type":393,"tag":427,"props":2154,"children":2155},{"style":439},[2156],{"type":398,"value":2157},"(avg_rating)\n",{"type":393,"tag":962,"props":2159,"children":2161},{"id":2160},"cross-tabulation-with-pdcrosstab",[2162],{"type":398,"value":2163},"🔄 Cross Tabulation with pd.crosstab()",{"type":393,"tag":401,"props":2165,"children":2166},{},[2167],{"type":398,"value":2168},"Cross-tabulation is perfect for analyzing relationships between categorical variables:",{"type":393,"tag":974,"props":2170,"children":2174},{"emoji":2171,"title":2172,"type":2173},"🔄","Crosstab vs Pivot Table","success",[2175,2183,2206,2214,2237],{"type":393,"tag":401,"props":2176,"children":2177},{},[2178],{"type":393,"tag":984,"props":2179,"children":2180},{},[2181],{"type":398,"value":2182},"pd.crosstab():",{"type":393,"tag":990,"props":2184,"children":2185},{},[2186,2191,2196,2201],{"type":393,"tag":994,"props":2187,"children":2188},{},[2189],{"type":398,"value":2190},"Specifically for counting occurrences",{"type":393,"tag":994,"props":2192,"children":2193},{},[2194],{"type":398,"value":2195},"Great for categorical data analysis",{"type":393,"tag":994,"props":2197,"children":2198},{},[2199],{"type":398,"value":2200},"Simpler syntax for frequency tables",{"type":393,"tag":994,"props":2202,"children":2203},{},[2204],{"type":398,"value":2205},"Built-in percentage calculations",{"type":393,"tag":401,"props":2207,"children":2208},{},[2209],{"type":393,"tag":984,"props":2210,"children":2211},{},[2212],{"type":398,"value":2213},"pd.pivot_table():",{"type":393,"tag":990,"props":2215,"children":2216},{},[2217,2222,2227,2232],{"type":393,"tag":994,"props":2218,"children":2219},{},[2220],{"type":398,"value":2221},"More flexible aggregation functions",{"type":393,"tag":994,"props":2223,"children":2224},{},[2225],{"type":398,"value":2226},"Can handle multiple value columns",{"type":393,"tag":994,"props":2228,"children":2229},{},[2230],{"type":398,"value":2231},"Better for numerical summaries",{"type":393,"tag":994,"props":2233,"children":2234},{},[2235],{"type":398,"value":2236},"More customization options",{"type":393,"tag":401,"props":2238,"children":2239},{},[2240,2245,2247,2252],{"type":393,"tag":984,"props":2241,"children":2242},{},[2243],{"type":398,"value":2244},"Use crosstab when:",{"type":398,"value":2246}," Analyzing relationships between categories\n",{"type":393,"tag":984,"props":2248,"children":2249},{},[2250],{"type":398,"value":2251},"Use pivot_table when:",{"type":398,"value":2253}," Creating numerical summaries",{"type":393,"tag":412,"props":2255,"children":2256},{},[2257],{"type":393,"tag":416,"props":2258,"children":2260},{"code":2259,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Customer survey data\nsurvey = pd.DataFrame({\n    'age_group': ['18-25', '26-35', '18-25', '36-45', '26-35', '18-25'],\n    'satisfaction': ['High', 'High', 'Medium', 'High', 'Medium', 'Low'],\n    'city': ['NYC', 'LA', 'NYC', 'Chicago', 'LA', 'Boston']\n})\n\nprint(\"Survey data:\")\nprint(survey)\nprint()\n\n# Cross-tabulation: Count by age group and satisfaction\ncrosstab = pd.crosstab(\n    survey['age_group'],\n    survey['satisfaction']\n)\nprint(\"Count by age group and satisfaction:\")\nprint(crosstab)\nprint()\n\n# Add row and column totals\ncrosstab_with_totals = pd.crosstab(\n    survey['age_group'],\n    survey['satisfaction'],\n    margins=True,\n    margins_name='Total'\n)\nprint(\"With totals:\")\nprint(crosstab_with_totals)\n",[2261],{"type":393,"tag":423,"props":2262,"children":2263},{"__ignoreMap":6},[2264,2283,2290,2298,2314,2377,2437,2501,2508,2515,2535,2547,2558,2565,2573,2590,2607,2623,2630,2650,2662,2673,2680,2688,2704,2719,2734,2755,2772,2779,2799],{"type":393,"tag":427,"props":2265,"children":2266},{"class":429,"line":11},[2267,2271,2275,2279],{"type":393,"tag":427,"props":2268,"children":2269},{"style":433},[2270],{"type":398,"value":436},{"type":393,"tag":427,"props":2272,"children":2273},{"style":439},[2274],{"type":398,"value":442},{"type":393,"tag":427,"props":2276,"children":2277},{"style":433},[2278],{"type":398,"value":447},{"type":393,"tag":427,"props":2280,"children":2281},{"style":439},[2282],{"type":398,"value":452},{"type":393,"tag":427,"props":2284,"children":2285},{"class":429,"line":27},[2286],{"type":393,"tag":427,"props":2287,"children":2288},{"emptyLinePlaceholder":12},[2289],{"type":398,"value":460},{"type":393,"tag":427,"props":2291,"children":2292},{"class":429,"line":36},[2293],{"type":393,"tag":427,"props":2294,"children":2295},{"style":466},[2296],{"type":398,"value":2297},"# Customer survey data\n",{"type":393,"tag":427,"props":2299,"children":2300},{"class":429,"line":45},[2301,2306,2310],{"type":393,"tag":427,"props":2302,"children":2303},{"style":439},[2304],{"type":398,"value":2305},"survey ",{"type":393,"tag":427,"props":2307,"children":2308},{"style":433},[2309],{"type":398,"value":482},{"type":393,"tag":427,"props":2311,"children":2312},{"style":439},[2313],{"type":398,"value":487},{"type":393,"tag":427,"props":2315,"children":2316},{"class":429,"line":54},[2317,2322,2326,2331,2335,2340,2344,2348,2352,2357,2361,2365,2369,2373],{"type":393,"tag":427,"props":2318,"children":2319},{"style":493},[2320],{"type":398,"value":2321},"    'age_group'",{"type":393,"tag":427,"props":2323,"children":2324},{"style":439},[2325],{"type":398,"value":501},{"type":393,"tag":427,"props":2327,"children":2328},{"style":493},[2329],{"type":398,"value":2330},"'18-25'",{"type":393,"tag":427,"props":2332,"children":2333},{"style":439},[2334],{"type":398,"value":511},{"type":393,"tag":427,"props":2336,"children":2337},{"style":493},[2338],{"type":398,"value":2339},"'26-35'",{"type":393,"tag":427,"props":2341,"children":2342},{"style":439},[2343],{"type":398,"value":511},{"type":393,"tag":427,"props":2345,"children":2346},{"style":493},[2347],{"type":398,"value":2330},{"type":393,"tag":427,"props":2349,"children":2350},{"style":439},[2351],{"type":398,"value":511},{"type":393,"tag":427,"props":2353,"children":2354},{"style":493},[2355],{"type":398,"value":2356},"'36-45'",{"type":393,"tag":427,"props":2358,"children":2359},{"style":439},[2360],{"type":398,"value":511},{"type":393,"tag":427,"props":2362,"children":2363},{"style":493},[2364],{"type":398,"value":2339},{"type":393,"tag":427,"props":2366,"children":2367},{"style":439},[2368],{"type":398,"value":511},{"type":393,"tag":427,"props":2370,"children":2371},{"style":493},[2372],{"type":398,"value":2330},{"type":393,"tag":427,"props":2374,"children":2375},{"style":439},[2376],{"type":398,"value":553},{"type":393,"tag":427,"props":2378,"children":2379},{"class":429,"line":63},[2380,2385,2389,2393,2397,2401,2405,2409,2413,2417,2421,2425,2429,2433],{"type":393,"tag":427,"props":2381,"children":2382},{"style":493},[2383],{"type":398,"value":2384},"    'satisfaction'",{"type":393,"tag":427,"props":2386,"children":2387},{"style":439},[2388],{"type":398,"value":501},{"type":393,"tag":427,"props":2390,"children":2391},{"style":493},[2392],{"type":398,"value":1737},{"type":393,"tag":427,"props":2394,"children":2395},{"style":439},[2396],{"type":398,"value":511},{"type":393,"tag":427,"props":2398,"children":2399},{"style":493},[2400],{"type":398,"value":1737},{"type":393,"tag":427,"props":2402,"children":2403},{"style":439},[2404],{"type":398,"value":511},{"type":393,"tag":427,"props":2406,"children":2407},{"style":493},[2408],{"type":398,"value":1763},{"type":393,"tag":427,"props":2410,"children":2411},{"style":439},[2412],{"type":398,"value":511},{"type":393,"tag":427,"props":2414,"children":2415},{"style":493},[2416],{"type":398,"value":1737},{"type":393,"tag":427,"props":2418,"children":2419},{"style":439},[2420],{"type":398,"value":511},{"type":393,"tag":427,"props":2422,"children":2423},{"style":493},[2424],{"type":398,"value":1763},{"type":393,"tag":427,"props":2426,"children":2427},{"style":439},[2428],{"type":398,"value":511},{"type":393,"tag":427,"props":2430,"children":2431},{"style":493},[2432],{"type":398,"value":1746},{"type":393,"tag":427,"props":2434,"children":2435},{"style":439},[2436],{"type":398,"value":553},{"type":393,"tag":427,"props":2438,"children":2439},{"class":429,"line":72},[2440,2445,2449,2454,2458,2463,2467,2471,2475,2480,2484,2488,2492,2497],{"type":393,"tag":427,"props":2441,"children":2442},{"style":493},[2443],{"type":398,"value":2444},"    'city'",{"type":393,"tag":427,"props":2446,"children":2447},{"style":439},[2448],{"type":398,"value":501},{"type":393,"tag":427,"props":2450,"children":2451},{"style":493},[2452],{"type":398,"value":2453},"'NYC'",{"type":393,"tag":427,"props":2455,"children":2456},{"style":439},[2457],{"type":398,"value":511},{"type":393,"tag":427,"props":2459,"children":2460},{"style":493},[2461],{"type":398,"value":2462},"'LA'",{"type":393,"tag":427,"props":2464,"children":2465},{"style":439},[2466],{"type":398,"value":511},{"type":393,"tag":427,"props":2468,"children":2469},{"style":493},[2470],{"type":398,"value":2453},{"type":393,"tag":427,"props":2472,"children":2473},{"style":439},[2474],{"type":398,"value":511},{"type":393,"tag":427,"props":2476,"children":2477},{"style":493},[2478],{"type":398,"value":2479},"'Chicago'",{"type":393,"tag":427,"props":2481,"children":2482},{"style":439},[2483],{"type":398,"value":511},{"type":393,"tag":427,"props":2485,"children":2486},{"style":493},[2487],{"type":398,"value":2462},{"type":393,"tag":427,"props":2489,"children":2490},{"style":439},[2491],{"type":398,"value":511},{"type":393,"tag":427,"props":2493,"children":2494},{"style":493},[2495],{"type":398,"value":2496},"'Boston'",{"type":393,"tag":427,"props":2498,"children":2499},{"style":439},[2500],{"type":398,"value":745},{"type":393,"tag":427,"props":2502,"children":2503},{"class":429,"line":83},[2504],{"type":393,"tag":427,"props":2505,"children":2506},{"style":439},[2507],{"type":398,"value":753},{"type":393,"tag":427,"props":2509,"children":2510},{"class":429,"line":92},[2511],{"type":393,"tag":427,"props":2512,"children":2513},{"emptyLinePlaceholder":12},[2514],{"type":398,"value":460},{"type":393,"tag":427,"props":2516,"children":2517},{"class":429,"line":101},[2518,2522,2526,2531],{"type":393,"tag":427,"props":2519,"children":2520},{"style":692},[2521],{"type":398,"value":768},{"type":393,"tag":427,"props":2523,"children":2524},{"style":439},[2525],{"type":398,"value":773},{"type":393,"tag":427,"props":2527,"children":2528},{"style":493},[2529],{"type":398,"value":2530},"\"Survey data:\"",{"type":393,"tag":427,"props":2532,"children":2533},{"style":439},[2534],{"type":398,"value":783},{"type":393,"tag":427,"props":2536,"children":2537},{"class":429,"line":110},[2538,2542],{"type":393,"tag":427,"props":2539,"children":2540},{"style":692},[2541],{"type":398,"value":768},{"type":393,"tag":427,"props":2543,"children":2544},{"style":439},[2545],{"type":398,"value":2546},"(survey)\n",{"type":393,"tag":427,"props":2548,"children":2549},{"class":429,"line":121},[2550,2554],{"type":393,"tag":427,"props":2551,"children":2552},{"style":692},[2553],{"type":398,"value":768},{"type":393,"tag":427,"props":2555,"children":2556},{"style":439},[2557],{"type":398,"value":807},{"type":393,"tag":427,"props":2559,"children":2560},{"class":429,"line":130},[2561],{"type":393,"tag":427,"props":2562,"children":2563},{"emptyLinePlaceholder":12},[2564],{"type":398,"value":460},{"type":393,"tag":427,"props":2566,"children":2567},{"class":429,"line":139},[2568],{"type":393,"tag":427,"props":2569,"children":2570},{"style":466},[2571],{"type":398,"value":2572},"# Cross-tabulation: Count by age group and satisfaction\n",{"type":393,"tag":427,"props":2574,"children":2575},{"class":429,"line":148},[2576,2581,2585],{"type":393,"tag":427,"props":2577,"children":2578},{"style":439},[2579],{"type":398,"value":2580},"crosstab ",{"type":393,"tag":427,"props":2582,"children":2583},{"style":433},[2584],{"type":398,"value":482},{"type":393,"tag":427,"props":2586,"children":2587},{"style":439},[2588],{"type":398,"value":2589}," pd.crosstab(\n",{"type":393,"tag":427,"props":2591,"children":2592},{"class":429,"line":159},[2593,2598,2603],{"type":393,"tag":427,"props":2594,"children":2595},{"style":439},[2596],{"type":398,"value":2597},"    survey[",{"type":393,"tag":427,"props":2599,"children":2600},{"style":493},[2601],{"type":398,"value":2602},"'age_group'",{"type":393,"tag":427,"props":2604,"children":2605},{"style":439},[2606],{"type":398,"value":553},{"type":393,"tag":427,"props":2608,"children":2609},{"class":429,"line":168},[2610,2614,2619],{"type":393,"tag":427,"props":2611,"children":2612},{"style":439},[2613],{"type":398,"value":2597},{"type":393,"tag":427,"props":2615,"children":2616},{"style":493},[2617],{"type":398,"value":2618},"'satisfaction'",{"type":393,"tag":427,"props":2620,"children":2621},{"style":439},[2622],{"type":398,"value":745},{"type":393,"tag":427,"props":2624,"children":2625},{"class":429,"line":177},[2626],{"type":393,"tag":427,"props":2627,"children":2628},{"style":439},[2629],{"type":398,"value":783},{"type":393,"tag":427,"props":2631,"children":2632},{"class":429,"line":186},[2633,2637,2641,2646],{"type":393,"tag":427,"props":2634,"children":2635},{"style":692},[2636],{"type":398,"value":768},{"type":393,"tag":427,"props":2638,"children":2639},{"style":439},[2640],{"type":398,"value":773},{"type":393,"tag":427,"props":2642,"children":2643},{"style":493},[2644],{"type":398,"value":2645},"\"Count by age group and satisfaction:\"",{"type":393,"tag":427,"props":2647,"children":2648},{"style":439},[2649],{"type":398,"value":783},{"type":393,"tag":427,"props":2651,"children":2652},{"class":429,"line":197},[2653,2657],{"type":393,"tag":427,"props":2654,"children":2655},{"style":692},[2656],{"type":398,"value":768},{"type":393,"tag":427,"props":2658,"children":2659},{"style":439},[2660],{"type":398,"value":2661},"(crosstab)\n",{"type":393,"tag":427,"props":2663,"children":2664},{"class":429,"line":206},[2665,2669],{"type":393,"tag":427,"props":2666,"children":2667},{"style":692},[2668],{"type":398,"value":768},{"type":393,"tag":427,"props":2670,"children":2671},{"style":439},[2672],{"type":398,"value":807},{"type":393,"tag":427,"props":2674,"children":2675},{"class":429,"line":215},[2676],{"type":393,"tag":427,"props":2677,"children":2678},{"emptyLinePlaceholder":12},[2679],{"type":398,"value":460},{"type":393,"tag":427,"props":2681,"children":2682},{"class":429,"line":224},[2683],{"type":393,"tag":427,"props":2684,"children":2685},{"style":466},[2686],{"type":398,"value":2687},"# Add row and column totals\n",{"type":393,"tag":427,"props":2689,"children":2690},{"class":429,"line":233},[2691,2696,2700],{"type":393,"tag":427,"props":2692,"children":2693},{"style":439},[2694],{"type":398,"value":2695},"crosstab_with_totals ",{"type":393,"tag":427,"props":2697,"children":2698},{"style":433},[2699],{"type":398,"value":482},{"type":393,"tag":427,"props":2701,"children":2702},{"style":439},[2703],{"type":398,"value":2589},{"type":393,"tag":427,"props":2705,"children":2706},{"class":429,"line":244},[2707,2711,2715],{"type":393,"tag":427,"props":2708,"children":2709},{"style":439},[2710],{"type":398,"value":2597},{"type":393,"tag":427,"props":2712,"children":2713},{"style":493},[2714],{"type":398,"value":2602},{"type":393,"tag":427,"props":2716,"children":2717},{"style":439},[2718],{"type":398,"value":553},{"type":393,"tag":427,"props":2720,"children":2721},{"class":429,"line":253},[2722,2726,2730],{"type":393,"tag":427,"props":2723,"children":2724},{"style":439},[2725],{"type":398,"value":2597},{"type":393,"tag":427,"props":2727,"children":2728},{"style":493},[2729],{"type":398,"value":2618},{"type":393,"tag":427,"props":2731,"children":2732},{"style":439},[2733],{"type":398,"value":553},{"type":393,"tag":427,"props":2735,"children":2736},{"class":429,"line":262},[2737,2742,2746,2751],{"type":393,"tag":427,"props":2738,"children":2739},{"style":845},[2740],{"type":398,"value":2741},"    margins",{"type":393,"tag":427,"props":2743,"children":2744},{"style":433},[2745],{"type":398,"value":482},{"type":393,"tag":427,"props":2747,"children":2748},{"style":692},[2749],{"type":398,"value":2750},"True",{"type":393,"tag":427,"props":2752,"children":2753},{"style":439},[2754],{"type":398,"value":862},{"type":393,"tag":427,"props":2756,"children":2757},{"class":429,"line":271},[2758,2763,2767],{"type":393,"tag":427,"props":2759,"children":2760},{"style":845},[2761],{"type":398,"value":2762},"    margins_name",{"type":393,"tag":427,"props":2764,"children":2765},{"style":433},[2766],{"type":398,"value":482},{"type":393,"tag":427,"props":2768,"children":2769},{"style":493},[2770],{"type":398,"value":2771},"'Total'\n",{"type":393,"tag":427,"props":2773,"children":2774},{"class":429,"line":281},[2775],{"type":393,"tag":427,"props":2776,"children":2777},{"style":439},[2778],{"type":398,"value":783},{"type":393,"tag":427,"props":2780,"children":2781},{"class":429,"line":290},[2782,2786,2790,2795],{"type":393,"tag":427,"props":2783,"children":2784},{"style":692},[2785],{"type":398,"value":768},{"type":393,"tag":427,"props":2787,"children":2788},{"style":439},[2789],{"type":398,"value":773},{"type":393,"tag":427,"props":2791,"children":2792},{"style":493},[2793],{"type":398,"value":2794},"\"With totals:\"",{"type":393,"tag":427,"props":2796,"children":2797},{"style":439},[2798],{"type":398,"value":783},{"type":393,"tag":427,"props":2800,"children":2801},{"class":429,"line":299},[2802,2806],{"type":393,"tag":427,"props":2803,"children":2804},{"style":692},[2805],{"type":398,"value":768},{"type":393,"tag":427,"props":2807,"children":2808},{"style":439},[2809],{"type":398,"value":2810},"(crosstab_with_totals)\n",{"type":393,"tag":1548,"props":2812,"children":2814},{"id":2813},"percentage-analysis",[2815],{"type":398,"value":2816},"Percentage Analysis",{"type":393,"tag":412,"props":2818,"children":2819},{},[2820],{"type":393,"tag":416,"props":2821,"children":2823},{"code":2822,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Customer preferences\npreferences = pd.DataFrame({\n    'age_group': ['Young', 'Middle', 'Young', 'Senior', 'Middle', 'Young'],\n    'product_type': ['Tech', 'Books', 'Books', 'Tech', 'Tech', 'Tech'],\n    'purchase': ['Yes', 'No', 'Yes', 'Yes', 'No', 'Yes']\n})\n\nprint(\"Customer preferences:\")\nprint(preferences)\nprint()\n\n# Percentage by row (what % of each age group purchased)\npct_by_row = pd.crosstab(\n    preferences['age_group'],\n    preferences['purchase'],\n    normalize='index'  # Normalize by row\n) * 100\n\nprint(\"Purchase rate by age group (%):\")\nprint(pct_by_row.round(1))\nprint()\n\n# Percentage by column (what % of purchasers are in each age group)\npct_by_col = pd.crosstab(\n    preferences['age_group'],\n    preferences['purchase'],\n    normalize='columns'  # Normalize by column\n) * 100\n\nprint(\"Age group distribution of purchasers (%):\")\nprint(pct_by_col.round(1))\n",[2824],{"type":393,"tag":423,"props":2825,"children":2826},{"__ignoreMap":6},[2827,2846,2853,2861,2877,2938,3000,3062,3069,3076,3096,3108,3119,3126,3134,3150,3166,3182,3204,3222,3229,3249,3271,3282,3289,3297,3313,3328,3343,3364,3379,3386,3406],{"type":393,"tag":427,"props":2828,"children":2829},{"class":429,"line":11},[2830,2834,2838,2842],{"type":393,"tag":427,"props":2831,"children":2832},{"style":433},[2833],{"type":398,"value":436},{"type":393,"tag":427,"props":2835,"children":2836},{"style":439},[2837],{"type":398,"value":442},{"type":393,"tag":427,"props":2839,"children":2840},{"style":433},[2841],{"type":398,"value":447},{"type":393,"tag":427,"props":2843,"children":2844},{"style":439},[2845],{"type":398,"value":452},{"type":393,"tag":427,"props":2847,"children":2848},{"class":429,"line":27},[2849],{"type":393,"tag":427,"props":2850,"children":2851},{"emptyLinePlaceholder":12},[2852],{"type":398,"value":460},{"type":393,"tag":427,"props":2854,"children":2855},{"class":429,"line":36},[2856],{"type":393,"tag":427,"props":2857,"children":2858},{"style":466},[2859],{"type":398,"value":2860},"# Customer preferences\n",{"type":393,"tag":427,"props":2862,"children":2863},{"class":429,"line":45},[2864,2869,2873],{"type":393,"tag":427,"props":2865,"children":2866},{"style":439},[2867],{"type":398,"value":2868},"preferences ",{"type":393,"tag":427,"props":2870,"children":2871},{"style":433},[2872],{"type":398,"value":482},{"type":393,"tag":427,"props":2874,"children":2875},{"style":439},[2876],{"type":398,"value":487},{"type":393,"tag":427,"props":2878,"children":2879},{"class":429,"line":54},[2880,2884,2888,2893,2897,2902,2906,2910,2914,2918,2922,2926,2930,2934],{"type":393,"tag":427,"props":2881,"children":2882},{"style":493},[2883],{"type":398,"value":2321},{"type":393,"tag":427,"props":2885,"children":2886},{"style":439},[2887],{"type":398,"value":501},{"type":393,"tag":427,"props":2889,"children":2890},{"style":493},[2891],{"type":398,"value":2892},"'Young'",{"type":393,"tag":427,"props":2894,"children":2895},{"style":439},[2896],{"type":398,"value":511},{"type":393,"tag":427,"props":2898,"children":2899},{"style":493},[2900],{"type":398,"value":2901},"'Middle'",{"type":393,"tag":427,"props":2903,"children":2904},{"style":439},[2905],{"type":398,"value":511},{"type":393,"tag":427,"props":2907,"children":2908},{"style":493},[2909],{"type":398,"value":2892},{"type":393,"tag":427,"props":2911,"children":2912},{"style":439},[2913],{"type":398,"value":511},{"type":393,"tag":427,"props":2915,"children":2916},{"style":493},[2917],{"type":398,"value":1240},{"type":393,"tag":427,"props":2919,"children":2920},{"style":439},[2921],{"type":398,"value":511},{"type":393,"tag":427,"props":2923,"children":2924},{"style":493},[2925],{"type":398,"value":2901},{"type":393,"tag":427,"props":2927,"children":2928},{"style":439},[2929],{"type":398,"value":511},{"type":393,"tag":427,"props":2931,"children":2932},{"style":493},[2933],{"type":398,"value":2892},{"type":393,"tag":427,"props":2935,"children":2936},{"style":439},[2937],{"type":398,"value":553},{"type":393,"tag":427,"props":2939,"children":2940},{"class":429,"line":63},[2941,2946,2950,2955,2959,2964,2968,2972,2976,2980,2984,2988,2992,2996],{"type":393,"tag":427,"props":2942,"children":2943},{"style":493},[2944],{"type":398,"value":2945},"    'product_type'",{"type":393,"tag":427,"props":2947,"children":2948},{"style":439},[2949],{"type":398,"value":501},{"type":393,"tag":427,"props":2951,"children":2952},{"style":493},[2953],{"type":398,"value":2954},"'Tech'",{"type":393,"tag":427,"props":2956,"children":2957},{"style":439},[2958],{"type":398,"value":511},{"type":393,"tag":427,"props":2960,"children":2961},{"style":493},[2962],{"type":398,"value":2963},"'Books'",{"type":393,"tag":427,"props":2965,"children":2966},{"style":439},[2967],{"type":398,"value":511},{"type":393,"tag":427,"props":2969,"children":2970},{"style":493},[2971],{"type":398,"value":2963},{"type":393,"tag":427,"props":2973,"children":2974},{"style":439},[2975],{"type":398,"value":511},{"type":393,"tag":427,"props":2977,"children":2978},{"style":493},[2979],{"type":398,"value":2954},{"type":393,"tag":427,"props":2981,"children":2982},{"style":439},[2983],{"type":398,"value":511},{"type":393,"tag":427,"props":2985,"children":2986},{"style":493},[2987],{"type":398,"value":2954},{"type":393,"tag":427,"props":2989,"children":2990},{"style":439},[2991],{"type":398,"value":511},{"type":393,"tag":427,"props":2993,"children":2994},{"style":493},[2995],{"type":398,"value":2954},{"type":393,"tag":427,"props":2997,"children":2998},{"style":439},[2999],{"type":398,"value":553},{"type":393,"tag":427,"props":3001,"children":3002},{"class":429,"line":72},[3003,3008,3012,3017,3021,3026,3030,3034,3038,3042,3046,3050,3054,3058],{"type":393,"tag":427,"props":3004,"children":3005},{"style":493},[3006],{"type":398,"value":3007},"    'purchase'",{"type":393,"tag":427,"props":3009,"children":3010},{"style":439},[3011],{"type":398,"value":501},{"type":393,"tag":427,"props":3013,"children":3014},{"style":493},[3015],{"type":398,"value":3016},"'Yes'",{"type":393,"tag":427,"props":3018,"children":3019},{"style":439},[3020],{"type":398,"value":511},{"type":393,"tag":427,"props":3022,"children":3023},{"style":493},[3024],{"type":398,"value":3025},"'No'",{"type":393,"tag":427,"props":3027,"children":3028},{"style":439},[3029],{"type":398,"value":511},{"type":393,"tag":427,"props":3031,"children":3032},{"style":493},[3033],{"type":398,"value":3016},{"type":393,"tag":427,"props":3035,"children":3036},{"style":439},[3037],{"type":398,"value":511},{"type":393,"tag":427,"props":3039,"children":3040},{"style":493},[3041],{"type":398,"value":3016},{"type":393,"tag":427,"props":3043,"children":3044},{"style":439},[3045],{"type":398,"value":511},{"type":393,"tag":427,"props":3047,"children":3048},{"style":493},[3049],{"type":398,"value":3025},{"type":393,"tag":427,"props":3051,"children":3052},{"style":439},[3053],{"type":398,"value":511},{"type":393,"tag":427,"props":3055,"children":3056},{"style":493},[3057],{"type":398,"value":3016},{"type":393,"tag":427,"props":3059,"children":3060},{"style":439},[3061],{"type":398,"value":745},{"type":393,"tag":427,"props":3063,"children":3064},{"class":429,"line":83},[3065],{"type":393,"tag":427,"props":3066,"children":3067},{"style":439},[3068],{"type":398,"value":753},{"type":393,"tag":427,"props":3070,"children":3071},{"class":429,"line":92},[3072],{"type":393,"tag":427,"props":3073,"children":3074},{"emptyLinePlaceholder":12},[3075],{"type":398,"value":460},{"type":393,"tag":427,"props":3077,"children":3078},{"class":429,"line":101},[3079,3083,3087,3092],{"type":393,"tag":427,"props":3080,"children":3081},{"style":692},[3082],{"type":398,"value":768},{"type":393,"tag":427,"props":3084,"children":3085},{"style":439},[3086],{"type":398,"value":773},{"type":393,"tag":427,"props":3088,"children":3089},{"style":493},[3090],{"type":398,"value":3091},"\"Customer preferences:\"",{"type":393,"tag":427,"props":3093,"children":3094},{"style":439},[3095],{"type":398,"value":783},{"type":393,"tag":427,"props":3097,"children":3098},{"class":429,"line":110},[3099,3103],{"type":393,"tag":427,"props":3100,"children":3101},{"style":692},[3102],{"type":398,"value":768},{"type":393,"tag":427,"props":3104,"children":3105},{"style":439},[3106],{"type":398,"value":3107},"(preferences)\n",{"type":393,"tag":427,"props":3109,"children":3110},{"class":429,"line":121},[3111,3115],{"type":393,"tag":427,"props":3112,"children":3113},{"style":692},[3114],{"type":398,"value":768},{"type":393,"tag":427,"props":3116,"children":3117},{"style":439},[3118],{"type":398,"value":807},{"type":393,"tag":427,"props":3120,"children":3121},{"class":429,"line":130},[3122],{"type":393,"tag":427,"props":3123,"children":3124},{"emptyLinePlaceholder":12},[3125],{"type":398,"value":460},{"type":393,"tag":427,"props":3127,"children":3128},{"class":429,"line":139},[3129],{"type":393,"tag":427,"props":3130,"children":3131},{"style":466},[3132],{"type":398,"value":3133},"# Percentage by row (what % of each age group purchased)\n",{"type":393,"tag":427,"props":3135,"children":3136},{"class":429,"line":148},[3137,3142,3146],{"type":393,"tag":427,"props":3138,"children":3139},{"style":439},[3140],{"type":398,"value":3141},"pct_by_row ",{"type":393,"tag":427,"props":3143,"children":3144},{"style":433},[3145],{"type":398,"value":482},{"type":393,"tag":427,"props":3147,"children":3148},{"style":439},[3149],{"type":398,"value":2589},{"type":393,"tag":427,"props":3151,"children":3152},{"class":429,"line":159},[3153,3158,3162],{"type":393,"tag":427,"props":3154,"children":3155},{"style":439},[3156],{"type":398,"value":3157},"    preferences[",{"type":393,"tag":427,"props":3159,"children":3160},{"style":493},[3161],{"type":398,"value":2602},{"type":393,"tag":427,"props":3163,"children":3164},{"style":439},[3165],{"type":398,"value":553},{"type":393,"tag":427,"props":3167,"children":3168},{"class":429,"line":168},[3169,3173,3178],{"type":393,"tag":427,"props":3170,"children":3171},{"style":439},[3172],{"type":398,"value":3157},{"type":393,"tag":427,"props":3174,"children":3175},{"style":493},[3176],{"type":398,"value":3177},"'purchase'",{"type":393,"tag":427,"props":3179,"children":3180},{"style":439},[3181],{"type":398,"value":553},{"type":393,"tag":427,"props":3183,"children":3184},{"class":429,"line":177},[3185,3190,3194,3199],{"type":393,"tag":427,"props":3186,"children":3187},{"style":845},[3188],{"type":398,"value":3189},"    normalize",{"type":393,"tag":427,"props":3191,"children":3192},{"style":433},[3193],{"type":398,"value":482},{"type":393,"tag":427,"props":3195,"children":3196},{"style":493},[3197],{"type":398,"value":3198},"'index'",{"type":393,"tag":427,"props":3200,"children":3201},{"style":466},[3202],{"type":398,"value":3203},"  # Normalize by row\n",{"type":393,"tag":427,"props":3205,"children":3206},{"class":429,"line":186},[3207,3212,3217],{"type":393,"tag":427,"props":3208,"children":3209},{"style":439},[3210],{"type":398,"value":3211},") ",{"type":393,"tag":427,"props":3213,"children":3214},{"style":433},[3215],{"type":398,"value":3216},"*",{"type":393,"tag":427,"props":3218,"children":3219},{"style":692},[3220],{"type":398,"value":3221}," 100\n",{"type":393,"tag":427,"props":3223,"children":3224},{"class":429,"line":197},[3225],{"type":393,"tag":427,"props":3226,"children":3227},{"emptyLinePlaceholder":12},[3228],{"type":398,"value":460},{"type":393,"tag":427,"props":3230,"children":3231},{"class":429,"line":206},[3232,3236,3240,3245],{"type":393,"tag":427,"props":3233,"children":3234},{"style":692},[3235],{"type":398,"value":768},{"type":393,"tag":427,"props":3237,"children":3238},{"style":439},[3239],{"type":398,"value":773},{"type":393,"tag":427,"props":3241,"children":3242},{"style":493},[3243],{"type":398,"value":3244},"\"Purchase rate by age group (%):\"",{"type":393,"tag":427,"props":3246,"children":3247},{"style":439},[3248],{"type":398,"value":783},{"type":393,"tag":427,"props":3250,"children":3251},{"class":429,"line":215},[3252,3256,3261,3266],{"type":393,"tag":427,"props":3253,"children":3254},{"style":692},[3255],{"type":398,"value":768},{"type":393,"tag":427,"props":3257,"children":3258},{"style":439},[3259],{"type":398,"value":3260},"(pct_by_row.round(",{"type":393,"tag":427,"props":3262,"children":3263},{"style":692},[3264],{"type":398,"value":3265},"1",{"type":393,"tag":427,"props":3267,"children":3268},{"style":439},[3269],{"type":398,"value":3270},"))\n",{"type":393,"tag":427,"props":3272,"children":3273},{"class":429,"line":224},[3274,3278],{"type":393,"tag":427,"props":3275,"children":3276},{"style":692},[3277],{"type":398,"value":768},{"type":393,"tag":427,"props":3279,"children":3280},{"style":439},[3281],{"type":398,"value":807},{"type":393,"tag":427,"props":3283,"children":3284},{"class":429,"line":233},[3285],{"type":393,"tag":427,"props":3286,"children":3287},{"emptyLinePlaceholder":12},[3288],{"type":398,"value":460},{"type":393,"tag":427,"props":3290,"children":3291},{"class":429,"line":244},[3292],{"type":393,"tag":427,"props":3293,"children":3294},{"style":466},[3295],{"type":398,"value":3296},"# Percentage by column (what % of purchasers are in each age group)\n",{"type":393,"tag":427,"props":3298,"children":3299},{"class":429,"line":253},[3300,3305,3309],{"type":393,"tag":427,"props":3301,"children":3302},{"style":439},[3303],{"type":398,"value":3304},"pct_by_col ",{"type":393,"tag":427,"props":3306,"children":3307},{"style":433},[3308],{"type":398,"value":482},{"type":393,"tag":427,"props":3310,"children":3311},{"style":439},[3312],{"type":398,"value":2589},{"type":393,"tag":427,"props":3314,"children":3315},{"class":429,"line":262},[3316,3320,3324],{"type":393,"tag":427,"props":3317,"children":3318},{"style":439},[3319],{"type":398,"value":3157},{"type":393,"tag":427,"props":3321,"children":3322},{"style":493},[3323],{"type":398,"value":2602},{"type":393,"tag":427,"props":3325,"children":3326},{"style":439},[3327],{"type":398,"value":553},{"type":393,"tag":427,"props":3329,"children":3330},{"class":429,"line":271},[3331,3335,3339],{"type":393,"tag":427,"props":3332,"children":3333},{"style":439},[3334],{"type":398,"value":3157},{"type":393,"tag":427,"props":3336,"children":3337},{"style":493},[3338],{"type":398,"value":3177},{"type":393,"tag":427,"props":3340,"children":3341},{"style":439},[3342],{"type":398,"value":553},{"type":393,"tag":427,"props":3344,"children":3345},{"class":429,"line":281},[3346,3350,3354,3359],{"type":393,"tag":427,"props":3347,"children":3348},{"style":845},[3349],{"type":398,"value":3189},{"type":393,"tag":427,"props":3351,"children":3352},{"style":433},[3353],{"type":398,"value":482},{"type":393,"tag":427,"props":3355,"children":3356},{"style":493},[3357],{"type":398,"value":3358},"'columns'",{"type":393,"tag":427,"props":3360,"children":3361},{"style":466},[3362],{"type":398,"value":3363},"  # Normalize by column\n",{"type":393,"tag":427,"props":3365,"children":3366},{"class":429,"line":290},[3367,3371,3375],{"type":393,"tag":427,"props":3368,"children":3369},{"style":439},[3370],{"type":398,"value":3211},{"type":393,"tag":427,"props":3372,"children":3373},{"style":433},[3374],{"type":398,"value":3216},{"type":393,"tag":427,"props":3376,"children":3377},{"style":692},[3378],{"type":398,"value":3221},{"type":393,"tag":427,"props":3380,"children":3381},{"class":429,"line":299},[3382],{"type":393,"tag":427,"props":3383,"children":3384},{"emptyLinePlaceholder":12},[3385],{"type":398,"value":460},{"type":393,"tag":427,"props":3387,"children":3388},{"class":429,"line":308},[3389,3393,3397,3402],{"type":393,"tag":427,"props":3390,"children":3391},{"style":692},[3392],{"type":398,"value":768},{"type":393,"tag":427,"props":3394,"children":3395},{"style":439},[3396],{"type":398,"value":773},{"type":393,"tag":427,"props":3398,"children":3399},{"style":493},[3400],{"type":398,"value":3401},"\"Age group distribution of purchasers (%):\"",{"type":393,"tag":427,"props":3403,"children":3404},{"style":439},[3405],{"type":398,"value":783},{"type":393,"tag":427,"props":3407,"children":3408},{"class":429,"line":318},[3409,3413,3418,3422],{"type":393,"tag":427,"props":3410,"children":3411},{"style":692},[3412],{"type":398,"value":768},{"type":393,"tag":427,"props":3414,"children":3415},{"style":439},[3416],{"type":398,"value":3417},"(pct_by_col.round(",{"type":393,"tag":427,"props":3419,"children":3420},{"style":692},[3421],{"type":398,"value":3265},{"type":393,"tag":427,"props":3423,"children":3424},{"style":439},[3425],{"type":398,"value":3270},{"type":393,"tag":962,"props":3427,"children":3429},{"id":3428},"multi-level-pivot-tables",[3430],{"type":398,"value":3431},"📈 Multi-Level Pivot Tables",{"type":393,"tag":401,"props":3433,"children":3434},{},[3435],{"type":398,"value":3436},"You can create more complex pivot tables with multiple dimensions:",{"type":393,"tag":412,"props":3438,"children":3439},{},[3440],{"type":393,"tag":416,"props":3441,"children":3443},{"code":3442,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Sales data with multiple dimensions\nsales = pd.DataFrame({\n    'region': ['North', 'South', 'North', 'South', 'North', 'South'],\n    'product': ['A', 'A', 'B', 'B', 'A', 'B'],\n    'quarter': ['Q1', 'Q1', 'Q1', 'Q1', 'Q2', 'Q2'],\n    'salesperson': ['Alice', 'Bob', 'Alice', 'Bob', 'Charlie', 'Diana'],\n    'revenue': [10000, 15000, 8000, 12000, 11000, 9000]\n})\n\nprint(\"Sales data:\")\nprint(sales)\nprint()\n\n# Multi-level pivot table\nmulti_pivot = sales.pivot_table(\n    values='revenue',\n    index=['region', 'quarter'],  # Multiple row levels\n    columns='product',            # Single column level\n    aggfunc='sum',\n    fill_value=0\n)\nprint(\"Revenue by region, quarter, and product:\")\nprint(multi_pivot)\n",[3444],{"type":393,"tag":423,"props":3445,"children":3446},{"__ignoreMap":6},[3447,3466,3473,3481,3496,3555,3616,3675,3739,3804,3811,3818,3837,3848,3859,3866,3874,3890,3909,3948,3973,3993,4009,4016,4036],{"type":393,"tag":427,"props":3448,"children":3449},{"class":429,"line":11},[3450,3454,3458,3462],{"type":393,"tag":427,"props":3451,"children":3452},{"style":433},[3453],{"type":398,"value":436},{"type":393,"tag":427,"props":3455,"children":3456},{"style":439},[3457],{"type":398,"value":442},{"type":393,"tag":427,"props":3459,"children":3460},{"style":433},[3461],{"type":398,"value":447},{"type":393,"tag":427,"props":3463,"children":3464},{"style":439},[3465],{"type":398,"value":452},{"type":393,"tag":427,"props":3467,"children":3468},{"class":429,"line":27},[3469],{"type":393,"tag":427,"props":3470,"children":3471},{"emptyLinePlaceholder":12},[3472],{"type":398,"value":460},{"type":393,"tag":427,"props":3474,"children":3475},{"class":429,"line":36},[3476],{"type":393,"tag":427,"props":3477,"children":3478},{"style":466},[3479],{"type":398,"value":3480},"# Sales data with multiple dimensions\n",{"type":393,"tag":427,"props":3482,"children":3483},{"class":429,"line":45},[3484,3488,3492],{"type":393,"tag":427,"props":3485,"children":3486},{"style":439},[3487],{"type":398,"value":477},{"type":393,"tag":427,"props":3489,"children":3490},{"style":433},[3491],{"type":398,"value":482},{"type":393,"tag":427,"props":3493,"children":3494},{"style":439},[3495],{"type":398,"value":487},{"type":393,"tag":427,"props":3497,"children":3498},{"class":429,"line":54},[3499,3503,3507,3511,3515,3519,3523,3527,3531,3535,3539,3543,3547,3551],{"type":393,"tag":427,"props":3500,"children":3501},{"style":493},[3502],{"type":398,"value":496},{"type":393,"tag":427,"props":3504,"children":3505},{"style":439},[3506],{"type":398,"value":501},{"type":393,"tag":427,"props":3508,"children":3509},{"style":493},[3510],{"type":398,"value":506},{"type":393,"tag":427,"props":3512,"children":3513},{"style":439},[3514],{"type":398,"value":511},{"type":393,"tag":427,"props":3516,"children":3517},{"style":493},[3518],{"type":398,"value":516},{"type":393,"tag":427,"props":3520,"children":3521},{"style":439},[3522],{"type":398,"value":511},{"type":393,"tag":427,"props":3524,"children":3525},{"style":493},[3526],{"type":398,"value":506},{"type":393,"tag":427,"props":3528,"children":3529},{"style":439},[3530],{"type":398,"value":511},{"type":393,"tag":427,"props":3532,"children":3533},{"style":493},[3534],{"type":398,"value":516},{"type":393,"tag":427,"props":3536,"children":3537},{"style":439},[3538],{"type":398,"value":511},{"type":393,"tag":427,"props":3540,"children":3541},{"style":493},[3542],{"type":398,"value":506},{"type":393,"tag":427,"props":3544,"children":3545},{"style":439},[3546],{"type":398,"value":511},{"type":393,"tag":427,"props":3548,"children":3549},{"style":493},[3550],{"type":398,"value":516},{"type":393,"tag":427,"props":3552,"children":3553},{"style":439},[3554],{"type":398,"value":553},{"type":393,"tag":427,"props":3556,"children":3557},{"class":429,"line":63},[3558,3562,3566,3571,3575,3579,3583,3588,3592,3596,3600,3604,3608,3612],{"type":393,"tag":427,"props":3559,"children":3560},{"style":493},[3561],{"type":398,"value":561},{"type":393,"tag":427,"props":3563,"children":3564},{"style":439},[3565],{"type":398,"value":501},{"type":393,"tag":427,"props":3567,"children":3568},{"style":493},[3569],{"type":398,"value":3570},"'A'",{"type":393,"tag":427,"props":3572,"children":3573},{"style":439},[3574],{"type":398,"value":511},{"type":393,"tag":427,"props":3576,"children":3577},{"style":493},[3578],{"type":398,"value":3570},{"type":393,"tag":427,"props":3580,"children":3581},{"style":439},[3582],{"type":398,"value":511},{"type":393,"tag":427,"props":3584,"children":3585},{"style":493},[3586],{"type":398,"value":3587},"'B'",{"type":393,"tag":427,"props":3589,"children":3590},{"style":439},[3591],{"type":398,"value":511},{"type":393,"tag":427,"props":3593,"children":3594},{"style":493},[3595],{"type":398,"value":3587},{"type":393,"tag":427,"props":3597,"children":3598},{"style":439},[3599],{"type":398,"value":511},{"type":393,"tag":427,"props":3601,"children":3602},{"style":493},[3603],{"type":398,"value":3570},{"type":393,"tag":427,"props":3605,"children":3606},{"style":439},[3607],{"type":398,"value":511},{"type":393,"tag":427,"props":3609,"children":3610},{"style":493},[3611],{"type":398,"value":3587},{"type":393,"tag":427,"props":3613,"children":3614},{"style":439},[3615],{"type":398,"value":553},{"type":393,"tag":427,"props":3617,"children":3618},{"class":429,"line":72},[3619,3623,3627,3631,3635,3639,3643,3647,3651,3655,3659,3663,3667,3671],{"type":393,"tag":427,"props":3620,"children":3621},{"style":493},[3622],{"type":398,"value":623},{"type":393,"tag":427,"props":3624,"children":3625},{"style":439},[3626],{"type":398,"value":501},{"type":393,"tag":427,"props":3628,"children":3629},{"style":493},[3630],{"type":398,"value":632},{"type":393,"tag":427,"props":3632,"children":3633},{"style":439},[3634],{"type":398,"value":511},{"type":393,"tag":427,"props":3636,"children":3637},{"style":493},[3638],{"type":398,"value":632},{"type":393,"tag":427,"props":3640,"children":3641},{"style":439},[3642],{"type":398,"value":511},{"type":393,"tag":427,"props":3644,"children":3645},{"style":493},[3646],{"type":398,"value":632},{"type":393,"tag":427,"props":3648,"children":3649},{"style":439},[3650],{"type":398,"value":511},{"type":393,"tag":427,"props":3652,"children":3653},{"style":493},[3654],{"type":398,"value":632},{"type":393,"tag":427,"props":3656,"children":3657},{"style":439},[3658],{"type":398,"value":511},{"type":393,"tag":427,"props":3660,"children":3661},{"style":493},[3662],{"type":398,"value":665},{"type":393,"tag":427,"props":3664,"children":3665},{"style":439},[3666],{"type":398,"value":511},{"type":393,"tag":427,"props":3668,"children":3669},{"style":493},[3670],{"type":398,"value":665},{"type":393,"tag":427,"props":3672,"children":3673},{"style":439},[3674],{"type":398,"value":553},{"type":393,"tag":427,"props":3676,"children":3677},{"class":429,"line":83},[3678,3683,3687,3692,3696,3701,3705,3709,3713,3717,3721,3726,3730,3735],{"type":393,"tag":427,"props":3679,"children":3680},{"style":493},[3681],{"type":398,"value":3682},"    'salesperson'",{"type":393,"tag":427,"props":3684,"children":3685},{"style":439},[3686],{"type":398,"value":501},{"type":393,"tag":427,"props":3688,"children":3689},{"style":493},[3690],{"type":398,"value":3691},"'Alice'",{"type":393,"tag":427,"props":3693,"children":3694},{"style":439},[3695],{"type":398,"value":511},{"type":393,"tag":427,"props":3697,"children":3698},{"style":493},[3699],{"type":398,"value":3700},"'Bob'",{"type":393,"tag":427,"props":3702,"children":3703},{"style":439},[3704],{"type":398,"value":511},{"type":393,"tag":427,"props":3706,"children":3707},{"style":493},[3708],{"type":398,"value":3691},{"type":393,"tag":427,"props":3710,"children":3711},{"style":439},[3712],{"type":398,"value":511},{"type":393,"tag":427,"props":3714,"children":3715},{"style":493},[3716],{"type":398,"value":3700},{"type":393,"tag":427,"props":3718,"children":3719},{"style":439},[3720],{"type":398,"value":511},{"type":393,"tag":427,"props":3722,"children":3723},{"style":493},[3724],{"type":398,"value":3725},"'Charlie'",{"type":393,"tag":427,"props":3727,"children":3728},{"style":439},[3729],{"type":398,"value":511},{"type":393,"tag":427,"props":3731,"children":3732},{"style":493},[3733],{"type":398,"value":3734},"'Diana'",{"type":393,"tag":427,"props":3736,"children":3737},{"style":439},[3738],{"type":398,"value":553},{"type":393,"tag":427,"props":3740,"children":3741},{"class":429,"line":92},[3742,3746,3750,3755,3759,3764,3768,3773,3777,3782,3786,3791,3795,3800],{"type":393,"tag":427,"props":3743,"children":3744},{"style":493},[3745],{"type":398,"value":685},{"type":393,"tag":427,"props":3747,"children":3748},{"style":439},[3749],{"type":398,"value":501},{"type":393,"tag":427,"props":3751,"children":3752},{"style":692},[3753],{"type":398,"value":3754},"10000",{"type":393,"tag":427,"props":3756,"children":3757},{"style":439},[3758],{"type":398,"value":511},{"type":393,"tag":427,"props":3760,"children":3761},{"style":692},[3762],{"type":398,"value":3763},"15000",{"type":393,"tag":427,"props":3765,"children":3766},{"style":439},[3767],{"type":398,"value":511},{"type":393,"tag":427,"props":3769,"children":3770},{"style":692},[3771],{"type":398,"value":3772},"8000",{"type":393,"tag":427,"props":3774,"children":3775},{"style":439},[3776],{"type":398,"value":511},{"type":393,"tag":427,"props":3778,"children":3779},{"style":692},[3780],{"type":398,"value":3781},"12000",{"type":393,"tag":427,"props":3783,"children":3784},{"style":439},[3785],{"type":398,"value":511},{"type":393,"tag":427,"props":3787,"children":3788},{"style":692},[3789],{"type":398,"value":3790},"11000",{"type":393,"tag":427,"props":3792,"children":3793},{"style":439},[3794],{"type":398,"value":511},{"type":393,"tag":427,"props":3796,"children":3797},{"style":692},[3798],{"type":398,"value":3799},"9000",{"type":393,"tag":427,"props":3801,"children":3802},{"style":439},[3803],{"type":398,"value":745},{"type":393,"tag":427,"props":3805,"children":3806},{"class":429,"line":101},[3807],{"type":393,"tag":427,"props":3808,"children":3809},{"style":439},[3810],{"type":398,"value":753},{"type":393,"tag":427,"props":3812,"children":3813},{"class":429,"line":110},[3814],{"type":393,"tag":427,"props":3815,"children":3816},{"emptyLinePlaceholder":12},[3817],{"type":398,"value":460},{"type":393,"tag":427,"props":3819,"children":3820},{"class":429,"line":121},[3821,3825,3829,3833],{"type":393,"tag":427,"props":3822,"children":3823},{"style":692},[3824],{"type":398,"value":768},{"type":393,"tag":427,"props":3826,"children":3827},{"style":439},[3828],{"type":398,"value":773},{"type":393,"tag":427,"props":3830,"children":3831},{"style":493},[3832],{"type":398,"value":778},{"type":393,"tag":427,"props":3834,"children":3835},{"style":439},[3836],{"type":398,"value":783},{"type":393,"tag":427,"props":3838,"children":3839},{"class":429,"line":130},[3840,3844],{"type":393,"tag":427,"props":3841,"children":3842},{"style":692},[3843],{"type":398,"value":768},{"type":393,"tag":427,"props":3845,"children":3846},{"style":439},[3847],{"type":398,"value":795},{"type":393,"tag":427,"props":3849,"children":3850},{"class":429,"line":139},[3851,3855],{"type":393,"tag":427,"props":3852,"children":3853},{"style":692},[3854],{"type":398,"value":768},{"type":393,"tag":427,"props":3856,"children":3857},{"style":439},[3858],{"type":398,"value":807},{"type":393,"tag":427,"props":3860,"children":3861},{"class":429,"line":148},[3862],{"type":393,"tag":427,"props":3863,"children":3864},{"emptyLinePlaceholder":12},[3865],{"type":398,"value":460},{"type":393,"tag":427,"props":3867,"children":3868},{"class":429,"line":159},[3869],{"type":393,"tag":427,"props":3870,"children":3871},{"style":466},[3872],{"type":398,"value":3873},"# Multi-level pivot table\n",{"type":393,"tag":427,"props":3875,"children":3876},{"class":429,"line":168},[3877,3882,3886],{"type":393,"tag":427,"props":3878,"children":3879},{"style":439},[3880],{"type":398,"value":3881},"multi_pivot ",{"type":393,"tag":427,"props":3883,"children":3884},{"style":433},[3885],{"type":398,"value":482},{"type":393,"tag":427,"props":3887,"children":3888},{"style":439},[3889],{"type":398,"value":839},{"type":393,"tag":427,"props":3891,"children":3892},{"class":429,"line":177},[3893,3897,3901,3905],{"type":393,"tag":427,"props":3894,"children":3895},{"style":845},[3896],{"type":398,"value":848},{"type":393,"tag":427,"props":3898,"children":3899},{"style":433},[3900],{"type":398,"value":482},{"type":393,"tag":427,"props":3902,"children":3903},{"style":493},[3904],{"type":398,"value":857},{"type":393,"tag":427,"props":3906,"children":3907},{"style":439},[3908],{"type":398,"value":862},{"type":393,"tag":427,"props":3910,"children":3911},{"class":429,"line":186},[3912,3916,3920,3925,3929,3933,3938,3943],{"type":393,"tag":427,"props":3913,"children":3914},{"style":845},[3915],{"type":398,"value":870},{"type":393,"tag":427,"props":3917,"children":3918},{"style":433},[3919],{"type":398,"value":482},{"type":393,"tag":427,"props":3921,"children":3922},{"style":439},[3923],{"type":398,"value":3924},"[",{"type":393,"tag":427,"props":3926,"children":3927},{"style":493},[3928],{"type":398,"value":879},{"type":393,"tag":427,"props":3930,"children":3931},{"style":439},[3932],{"type":398,"value":511},{"type":393,"tag":427,"props":3934,"children":3935},{"style":493},[3936],{"type":398,"value":3937},"'quarter'",{"type":393,"tag":427,"props":3939,"children":3940},{"style":439},[3941],{"type":398,"value":3942},"],  ",{"type":393,"tag":427,"props":3944,"children":3945},{"style":466},[3946],{"type":398,"value":3947},"# Multiple row levels\n",{"type":393,"tag":427,"props":3949,"children":3950},{"class":429,"line":197},[3951,3955,3959,3963,3968],{"type":393,"tag":427,"props":3952,"children":3953},{"style":845},[3954],{"type":398,"value":891},{"type":393,"tag":427,"props":3956,"children":3957},{"style":433},[3958],{"type":398,"value":482},{"type":393,"tag":427,"props":3960,"children":3961},{"style":493},[3962],{"type":398,"value":900},{"type":393,"tag":427,"props":3964,"children":3965},{"style":439},[3966],{"type":398,"value":3967},",            ",{"type":393,"tag":427,"props":3969,"children":3970},{"style":466},[3971],{"type":398,"value":3972},"# Single column level\n",{"type":393,"tag":427,"props":3974,"children":3975},{"class":429,"line":206},[3976,3980,3984,3989],{"type":393,"tag":427,"props":3977,"children":3978},{"style":845},[3979],{"type":398,"value":912},{"type":393,"tag":427,"props":3981,"children":3982},{"style":433},[3983],{"type":398,"value":482},{"type":393,"tag":427,"props":3985,"children":3986},{"style":493},[3987],{"type":398,"value":3988},"'sum'",{"type":393,"tag":427,"props":3990,"children":3991},{"style":439},[3992],{"type":398,"value":862},{"type":393,"tag":427,"props":3994,"children":3995},{"class":429,"line":215},[3996,4000,4004],{"type":393,"tag":427,"props":3997,"children":3998},{"style":845},[3999],{"type":398,"value":1951},{"type":393,"tag":427,"props":4001,"children":4002},{"style":433},[4003],{"type":398,"value":482},{"type":393,"tag":427,"props":4005,"children":4006},{"style":692},[4007],{"type":398,"value":4008},"0\n",{"type":393,"tag":427,"props":4010,"children":4011},{"class":429,"line":224},[4012],{"type":393,"tag":427,"props":4013,"children":4014},{"style":439},[4015],{"type":398,"value":783},{"type":393,"tag":427,"props":4017,"children":4018},{"class":429,"line":233},[4019,4023,4027,4032],{"type":393,"tag":427,"props":4020,"children":4021},{"style":692},[4022],{"type":398,"value":768},{"type":393,"tag":427,"props":4024,"children":4025},{"style":439},[4026],{"type":398,"value":773},{"type":393,"tag":427,"props":4028,"children":4029},{"style":493},[4030],{"type":398,"value":4031},"\"Revenue by region, quarter, and product:\"",{"type":393,"tag":427,"props":4033,"children":4034},{"style":439},[4035],{"type":398,"value":783},{"type":393,"tag":427,"props":4037,"children":4038},{"class":429,"line":244},[4039,4043],{"type":393,"tag":427,"props":4040,"children":4041},{"style":692},[4042],{"type":398,"value":768},{"type":393,"tag":427,"props":4044,"children":4045},{"style":439},[4046],{"type":398,"value":4047},"(multi_pivot)\n",{"type":393,"tag":962,"props":4049,"children":4051},{"id":4050},"multiple-value-columns",[4052],{"type":398,"value":4053},"🔢 Multiple Value Columns",{"type":393,"tag":401,"props":4055,"children":4056},{},[4057],{"type":398,"value":4058},"You can analyze multiple metrics in one pivot table:",{"type":393,"tag":412,"props":4060,"children":4061},{},[4062],{"type":393,"tag":416,"props":4063,"children":4065},{"code":4064,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Store performance data\nstores = pd.DataFrame({\n    'region': ['East', 'West', 'East', 'West', 'East'],\n    'quarter': ['Q1', 'Q1', 'Q2', 'Q2', 'Q1'],\n    'revenue': [50000, 75000, 55000, 80000, 48000],\n    'customers': [500, 750, 520, 800, 480]\n})\n\nprint(\"Store performance:\")\nprint(stores)\nprint()\n\n# Multiple value analysis\nmulti_value = stores.pivot_table(\n    values=['revenue', 'customers'],\n    index='region',\n    columns='quarter',\n    aggfunc='sum',\n    fill_value=0\n)\nprint(\"Revenue and customers by region and quarter:\")\nprint(multi_value)\n",[4066],{"type":393,"tag":423,"props":4067,"children":4068},{"__ignoreMap":6},[4069,4088,4095,4103,4119,4172,4223,4275,4332,4339,4346,4366,4378,4389,4396,4404,4421,4453,4472,4491,4510,4525,4532,4552],{"type":393,"tag":427,"props":4070,"children":4071},{"class":429,"line":11},[4072,4076,4080,4084],{"type":393,"tag":427,"props":4073,"children":4074},{"style":433},[4075],{"type":398,"value":436},{"type":393,"tag":427,"props":4077,"children":4078},{"style":439},[4079],{"type":398,"value":442},{"type":393,"tag":427,"props":4081,"children":4082},{"style":433},[4083],{"type":398,"value":447},{"type":393,"tag":427,"props":4085,"children":4086},{"style":439},[4087],{"type":398,"value":452},{"type":393,"tag":427,"props":4089,"children":4090},{"class":429,"line":27},[4091],{"type":393,"tag":427,"props":4092,"children":4093},{"emptyLinePlaceholder":12},[4094],{"type":398,"value":460},{"type":393,"tag":427,"props":4096,"children":4097},{"class":429,"line":36},[4098],{"type":393,"tag":427,"props":4099,"children":4100},{"style":466},[4101],{"type":398,"value":4102},"# Store performance data\n",{"type":393,"tag":427,"props":4104,"children":4105},{"class":429,"line":45},[4106,4111,4115],{"type":393,"tag":427,"props":4107,"children":4108},{"style":439},[4109],{"type":398,"value":4110},"stores ",{"type":393,"tag":427,"props":4112,"children":4113},{"style":433},[4114],{"type":398,"value":482},{"type":393,"tag":427,"props":4116,"children":4117},{"style":439},[4118],{"type":398,"value":487},{"type":393,"tag":427,"props":4120,"children":4121},{"class":429,"line":54},[4122,4126,4130,4135,4139,4144,4148,4152,4156,4160,4164,4168],{"type":393,"tag":427,"props":4123,"children":4124},{"style":493},[4125],{"type":398,"value":496},{"type":393,"tag":427,"props":4127,"children":4128},{"style":439},[4129],{"type":398,"value":501},{"type":393,"tag":427,"props":4131,"children":4132},{"style":493},[4133],{"type":398,"value":4134},"'East'",{"type":393,"tag":427,"props":4136,"children":4137},{"style":439},[4138],{"type":398,"value":511},{"type":393,"tag":427,"props":4140,"children":4141},{"style":493},[4142],{"type":398,"value":4143},"'West'",{"type":393,"tag":427,"props":4145,"children":4146},{"style":439},[4147],{"type":398,"value":511},{"type":393,"tag":427,"props":4149,"children":4150},{"style":493},[4151],{"type":398,"value":4134},{"type":393,"tag":427,"props":4153,"children":4154},{"style":439},[4155],{"type":398,"value":511},{"type":393,"tag":427,"props":4157,"children":4158},{"style":493},[4159],{"type":398,"value":4143},{"type":393,"tag":427,"props":4161,"children":4162},{"style":439},[4163],{"type":398,"value":511},{"type":393,"tag":427,"props":4165,"children":4166},{"style":493},[4167],{"type":398,"value":4134},{"type":393,"tag":427,"props":4169,"children":4170},{"style":439},[4171],{"type":398,"value":553},{"type":393,"tag":427,"props":4173,"children":4174},{"class":429,"line":63},[4175,4179,4183,4187,4191,4195,4199,4203,4207,4211,4215,4219],{"type":393,"tag":427,"props":4176,"children":4177},{"style":493},[4178],{"type":398,"value":623},{"type":393,"tag":427,"props":4180,"children":4181},{"style":439},[4182],{"type":398,"value":501},{"type":393,"tag":427,"props":4184,"children":4185},{"style":493},[4186],{"type":398,"value":632},{"type":393,"tag":427,"props":4188,"children":4189},{"style":439},[4190],{"type":398,"value":511},{"type":393,"tag":427,"props":4192,"children":4193},{"style":493},[4194],{"type":398,"value":632},{"type":393,"tag":427,"props":4196,"children":4197},{"style":439},[4198],{"type":398,"value":511},{"type":393,"tag":427,"props":4200,"children":4201},{"style":493},[4202],{"type":398,"value":665},{"type":393,"tag":427,"props":4204,"children":4205},{"style":439},[4206],{"type":398,"value":511},{"type":393,"tag":427,"props":4208,"children":4209},{"style":493},[4210],{"type":398,"value":665},{"type":393,"tag":427,"props":4212,"children":4213},{"style":439},[4214],{"type":398,"value":511},{"type":393,"tag":427,"props":4216,"children":4217},{"style":493},[4218],{"type":398,"value":632},{"type":393,"tag":427,"props":4220,"children":4221},{"style":439},[4222],{"type":398,"value":553},{"type":393,"tag":427,"props":4224,"children":4225},{"class":429,"line":72},[4226,4230,4234,4238,4242,4246,4250,4254,4258,4262,4266,4271],{"type":393,"tag":427,"props":4227,"children":4228},{"style":493},[4229],{"type":398,"value":685},{"type":393,"tag":427,"props":4231,"children":4232},{"style":439},[4233],{"type":398,"value":501},{"type":393,"tag":427,"props":4235,"children":4236},{"style":692},[4237],{"type":398,"value":695},{"type":393,"tag":427,"props":4239,"children":4240},{"style":439},[4241],{"type":398,"value":511},{"type":393,"tag":427,"props":4243,"children":4244},{"style":692},[4245],{"type":398,"value":704},{"type":393,"tag":427,"props":4247,"children":4248},{"style":439},[4249],{"type":398,"value":511},{"type":393,"tag":427,"props":4251,"children":4252},{"style":692},[4253],{"type":398,"value":1338},{"type":393,"tag":427,"props":4255,"children":4256},{"style":439},[4257],{"type":398,"value":511},{"type":393,"tag":427,"props":4259,"children":4260},{"style":692},[4261],{"type":398,"value":1302},{"type":393,"tag":427,"props":4263,"children":4264},{"style":439},[4265],{"type":398,"value":511},{"type":393,"tag":427,"props":4267,"children":4268},{"style":692},[4269],{"type":398,"value":4270},"48000",{"type":393,"tag":427,"props":4272,"children":4273},{"style":439},[4274],{"type":398,"value":553},{"type":393,"tag":427,"props":4276,"children":4277},{"class":429,"line":83},[4278,4283,4287,4292,4296,4301,4305,4310,4314,4319,4323,4328],{"type":393,"tag":427,"props":4279,"children":4280},{"style":493},[4281],{"type":398,"value":4282},"    'customers'",{"type":393,"tag":427,"props":4284,"children":4285},{"style":439},[4286],{"type":398,"value":501},{"type":393,"tag":427,"props":4288,"children":4289},{"style":692},[4290],{"type":398,"value":4291},"500",{"type":393,"tag":427,"props":4293,"children":4294},{"style":439},[4295],{"type":398,"value":511},{"type":393,"tag":427,"props":4297,"children":4298},{"style":692},[4299],{"type":398,"value":4300},"750",{"type":393,"tag":427,"props":4302,"children":4303},{"style":439},[4304],{"type":398,"value":511},{"type":393,"tag":427,"props":4306,"children":4307},{"style":692},[4308],{"type":398,"value":4309},"520",{"type":393,"tag":427,"props":4311,"children":4312},{"style":439},[4313],{"type":398,"value":511},{"type":393,"tag":427,"props":4315,"children":4316},{"style":692},[4317],{"type":398,"value":4318},"800",{"type":393,"tag":427,"props":4320,"children":4321},{"style":439},[4322],{"type":398,"value":511},{"type":393,"tag":427,"props":4324,"children":4325},{"style":692},[4326],{"type":398,"value":4327},"480",{"type":393,"tag":427,"props":4329,"children":4330},{"style":439},[4331],{"type":398,"value":745},{"type":393,"tag":427,"props":4333,"children":4334},{"class":429,"line":92},[4335],{"type":393,"tag":427,"props":4336,"children":4337},{"style":439},[4338],{"type":398,"value":753},{"type":393,"tag":427,"props":4340,"children":4341},{"class":429,"line":101},[4342],{"type":393,"tag":427,"props":4343,"children":4344},{"emptyLinePlaceholder":12},[4345],{"type":398,"value":460},{"type":393,"tag":427,"props":4347,"children":4348},{"class":429,"line":110},[4349,4353,4357,4362],{"type":393,"tag":427,"props":4350,"children":4351},{"style":692},[4352],{"type":398,"value":768},{"type":393,"tag":427,"props":4354,"children":4355},{"style":439},[4356],{"type":398,"value":773},{"type":393,"tag":427,"props":4358,"children":4359},{"style":493},[4360],{"type":398,"value":4361},"\"Store performance:\"",{"type":393,"tag":427,"props":4363,"children":4364},{"style":439},[4365],{"type":398,"value":783},{"type":393,"tag":427,"props":4367,"children":4368},{"class":429,"line":121},[4369,4373],{"type":393,"tag":427,"props":4370,"children":4371},{"style":692},[4372],{"type":398,"value":768},{"type":393,"tag":427,"props":4374,"children":4375},{"style":439},[4376],{"type":398,"value":4377},"(stores)\n",{"type":393,"tag":427,"props":4379,"children":4380},{"class":429,"line":130},[4381,4385],{"type":393,"tag":427,"props":4382,"children":4383},{"style":692},[4384],{"type":398,"value":768},{"type":393,"tag":427,"props":4386,"children":4387},{"style":439},[4388],{"type":398,"value":807},{"type":393,"tag":427,"props":4390,"children":4391},{"class":429,"line":139},[4392],{"type":393,"tag":427,"props":4393,"children":4394},{"emptyLinePlaceholder":12},[4395],{"type":398,"value":460},{"type":393,"tag":427,"props":4397,"children":4398},{"class":429,"line":148},[4399],{"type":393,"tag":427,"props":4400,"children":4401},{"style":466},[4402],{"type":398,"value":4403},"# Multiple value analysis\n",{"type":393,"tag":427,"props":4405,"children":4406},{"class":429,"line":159},[4407,4412,4416],{"type":393,"tag":427,"props":4408,"children":4409},{"style":439},[4410],{"type":398,"value":4411},"multi_value ",{"type":393,"tag":427,"props":4413,"children":4414},{"style":433},[4415],{"type":398,"value":482},{"type":393,"tag":427,"props":4417,"children":4418},{"style":439},[4419],{"type":398,"value":4420}," stores.pivot_table(\n",{"type":393,"tag":427,"props":4422,"children":4423},{"class":429,"line":168},[4424,4428,4432,4436,4440,4444,4449],{"type":393,"tag":427,"props":4425,"children":4426},{"style":845},[4427],{"type":398,"value":848},{"type":393,"tag":427,"props":4429,"children":4430},{"style":433},[4431],{"type":398,"value":482},{"type":393,"tag":427,"props":4433,"children":4434},{"style":439},[4435],{"type":398,"value":3924},{"type":393,"tag":427,"props":4437,"children":4438},{"style":493},[4439],{"type":398,"value":857},{"type":393,"tag":427,"props":4441,"children":4442},{"style":439},[4443],{"type":398,"value":511},{"type":393,"tag":427,"props":4445,"children":4446},{"style":493},[4447],{"type":398,"value":4448},"'customers'",{"type":393,"tag":427,"props":4450,"children":4451},{"style":439},[4452],{"type":398,"value":553},{"type":393,"tag":427,"props":4454,"children":4455},{"class":429,"line":177},[4456,4460,4464,4468],{"type":393,"tag":427,"props":4457,"children":4458},{"style":845},[4459],{"type":398,"value":870},{"type":393,"tag":427,"props":4461,"children":4462},{"style":433},[4463],{"type":398,"value":482},{"type":393,"tag":427,"props":4465,"children":4466},{"style":493},[4467],{"type":398,"value":879},{"type":393,"tag":427,"props":4469,"children":4470},{"style":439},[4471],{"type":398,"value":862},{"type":393,"tag":427,"props":4473,"children":4474},{"class":429,"line":186},[4475,4479,4483,4487],{"type":393,"tag":427,"props":4476,"children":4477},{"style":845},[4478],{"type":398,"value":891},{"type":393,"tag":427,"props":4480,"children":4481},{"style":433},[4482],{"type":398,"value":482},{"type":393,"tag":427,"props":4484,"children":4485},{"style":493},[4486],{"type":398,"value":3937},{"type":393,"tag":427,"props":4488,"children":4489},{"style":439},[4490],{"type":398,"value":862},{"type":393,"tag":427,"props":4492,"children":4493},{"class":429,"line":197},[4494,4498,4502,4506],{"type":393,"tag":427,"props":4495,"children":4496},{"style":845},[4497],{"type":398,"value":912},{"type":393,"tag":427,"props":4499,"children":4500},{"style":433},[4501],{"type":398,"value":482},{"type":393,"tag":427,"props":4503,"children":4504},{"style":493},[4505],{"type":398,"value":3988},{"type":393,"tag":427,"props":4507,"children":4508},{"style":439},[4509],{"type":398,"value":862},{"type":393,"tag":427,"props":4511,"children":4512},{"class":429,"line":206},[4513,4517,4521],{"type":393,"tag":427,"props":4514,"children":4515},{"style":845},[4516],{"type":398,"value":1951},{"type":393,"tag":427,"props":4518,"children":4519},{"style":433},[4520],{"type":398,"value":482},{"type":393,"tag":427,"props":4522,"children":4523},{"style":692},[4524],{"type":398,"value":4008},{"type":393,"tag":427,"props":4526,"children":4527},{"class":429,"line":215},[4528],{"type":393,"tag":427,"props":4529,"children":4530},{"style":439},[4531],{"type":398,"value":783},{"type":393,"tag":427,"props":4533,"children":4534},{"class":429,"line":224},[4535,4539,4543,4548],{"type":393,"tag":427,"props":4536,"children":4537},{"style":692},[4538],{"type":398,"value":768},{"type":393,"tag":427,"props":4540,"children":4541},{"style":439},[4542],{"type":398,"value":773},{"type":393,"tag":427,"props":4544,"children":4545},{"style":493},[4546],{"type":398,"value":4547},"\"Revenue and customers by region and quarter:\"",{"type":393,"tag":427,"props":4549,"children":4550},{"style":439},[4551],{"type":398,"value":783},{"type":393,"tag":427,"props":4553,"children":4554},{"class":429,"line":233},[4555,4559],{"type":393,"tag":427,"props":4556,"children":4557},{"style":692},[4558],{"type":398,"value":768},{"type":393,"tag":427,"props":4560,"children":4561},{"style":439},[4562],{"type":398,"value":4563},"(multi_value)\n",{"type":393,"tag":962,"props":4565,"children":4567},{"id":4566},"pivot-table-styling-and-formatting",[4568],{"type":398,"value":4569},"📊 Pivot Table Styling and Formatting",{"type":393,"tag":401,"props":4571,"children":4572},{},[4573],{"type":398,"value":4574},"Make your pivot tables more readable:",{"type":393,"tag":974,"props":4576,"children":4579},{"emoji":4577,"title":4578,"type":978},"🎨","Pivot Table Best Practices",[4580,4588,4626,4634,4657,4665],{"type":393,"tag":401,"props":4581,"children":4582},{},[4583],{"type":393,"tag":984,"props":4584,"children":4585},{},[4586],{"type":398,"value":4587},"Readability Tips:",{"type":393,"tag":990,"props":4589,"children":4590},{},[4591,4604,4609,4614],{"type":393,"tag":994,"props":4592,"children":4593},{},[4594,4596,4602],{"type":398,"value":4595},"Use ",{"type":393,"tag":423,"props":4597,"children":4599},{"className":4598},[],[4600],{"type":398,"value":4601},"fill_value=0",{"type":398,"value":4603}," to replace NaN with zeros",{"type":393,"tag":994,"props":4605,"children":4606},{},[4607],{"type":398,"value":4608},"Round numerical results for cleaner display",{"type":393,"tag":994,"props":4610,"children":4611},{},[4612],{"type":398,"value":4613},"Add meaningful column/index names",{"type":393,"tag":994,"props":4615,"children":4616},{},[4617,4618,4624],{"type":398,"value":4595},{"type":393,"tag":423,"props":4619,"children":4621},{"className":4620},[],[4622],{"type":398,"value":4623},"margins=True",{"type":398,"value":4625}," for totals",{"type":393,"tag":401,"props":4627,"children":4628},{},[4629],{"type":393,"tag":984,"props":4630,"children":4631},{},[4632],{"type":398,"value":4633},"Professional Formatting:",{"type":393,"tag":990,"props":4635,"children":4636},{},[4637,4642,4647,4652],{"type":393,"tag":994,"props":4638,"children":4639},{},[4640],{"type":398,"value":4641},"Round to appropriate decimal places",{"type":393,"tag":994,"props":4643,"children":4644},{},[4645],{"type":398,"value":4646},"Use currency formatting for money",{"type":393,"tag":994,"props":4648,"children":4649},{},[4650],{"type":398,"value":4651},"Add percentage symbols where appropriate",{"type":393,"tag":994,"props":4653,"children":4654},{},[4655],{"type":398,"value":4656},"Consider using styling for reports",{"type":393,"tag":401,"props":4658,"children":4659},{},[4660],{"type":393,"tag":984,"props":4661,"children":4662},{},[4663],{"type":398,"value":4664},"Performance:",{"type":393,"tag":990,"props":4666,"children":4667},{},[4668,4673,4678],{"type":393,"tag":994,"props":4669,"children":4670},{},[4671],{"type":398,"value":4672},"Test with small data first",{"type":393,"tag":994,"props":4674,"children":4675},{},[4676],{"type":398,"value":4677},"Consider memory usage with large datasets",{"type":393,"tag":994,"props":4679,"children":4680},{},[4681],{"type":398,"value":4682},"Use appropriate aggregation functions",{"type":393,"tag":412,"props":4684,"children":4685},{},[4686],{"type":393,"tag":416,"props":4687,"children":4689},{"code":4688,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Sales performance data\nperformance = pd.DataFrame({\n    'team': ['Alpha', 'Beta', 'Alpha', 'Beta', 'Alpha'],\n    'quarter': ['Q1', 'Q1', 'Q2', 'Q2', 'Q1'],\n    'revenue': [120000, 95000, 135000, 110000, 115000],\n    'target': [100000, 90000, 130000, 105000, 110000]\n})\n\nprint(\"Performance data:\")\nprint(performance)\nprint()\n\n# Formatted pivot table\nformatted_pivot = performance.pivot_table(\n    values=['revenue', 'target'],\n    index='team',\n    columns='quarter',\n    aggfunc='sum',\n    fill_value=0,\n    margins=True,\n    margins_name='Total'\n)\n\n# Round to thousands for readability\nformatted_pivot = (formatted_pivot / 1000).round(0).astype(int)\n\nprint(\"Revenue and targets by team and quarter (in thousands):\")\nprint(formatted_pivot)\n",[4690],{"type":393,"tag":423,"props":4691,"children":4692},{"__ignoreMap":6},[4693,4712,4719,4727,4743,4797,4848,4904,4960,4967,4974,4994,5006,5017,5024,5032,5049,5081,5101,5120,5139,5158,5177,5192,5199,5206,5214,5263,5270,5290],{"type":393,"tag":427,"props":4694,"children":4695},{"class":429,"line":11},[4696,4700,4704,4708],{"type":393,"tag":427,"props":4697,"children":4698},{"style":433},[4699],{"type":398,"value":436},{"type":393,"tag":427,"props":4701,"children":4702},{"style":439},[4703],{"type":398,"value":442},{"type":393,"tag":427,"props":4705,"children":4706},{"style":433},[4707],{"type":398,"value":447},{"type":393,"tag":427,"props":4709,"children":4710},{"style":439},[4711],{"type":398,"value":452},{"type":393,"tag":427,"props":4713,"children":4714},{"class":429,"line":27},[4715],{"type":393,"tag":427,"props":4716,"children":4717},{"emptyLinePlaceholder":12},[4718],{"type":398,"value":460},{"type":393,"tag":427,"props":4720,"children":4721},{"class":429,"line":36},[4722],{"type":393,"tag":427,"props":4723,"children":4724},{"style":466},[4725],{"type":398,"value":4726},"# Sales performance data\n",{"type":393,"tag":427,"props":4728,"children":4729},{"class":429,"line":45},[4730,4735,4739],{"type":393,"tag":427,"props":4731,"children":4732},{"style":439},[4733],{"type":398,"value":4734},"performance ",{"type":393,"tag":427,"props":4736,"children":4737},{"style":433},[4738],{"type":398,"value":482},{"type":393,"tag":427,"props":4740,"children":4741},{"style":439},[4742],{"type":398,"value":487},{"type":393,"tag":427,"props":4744,"children":4745},{"class":429,"line":54},[4746,4751,4755,4760,4764,4769,4773,4777,4781,4785,4789,4793],{"type":393,"tag":427,"props":4747,"children":4748},{"style":493},[4749],{"type":398,"value":4750},"    'team'",{"type":393,"tag":427,"props":4752,"children":4753},{"style":439},[4754],{"type":398,"value":501},{"type":393,"tag":427,"props":4756,"children":4757},{"style":493},[4758],{"type":398,"value":4759},"'Alpha'",{"type":393,"tag":427,"props":4761,"children":4762},{"style":439},[4763],{"type":398,"value":511},{"type":393,"tag":427,"props":4765,"children":4766},{"style":493},[4767],{"type":398,"value":4768},"'Beta'",{"type":393,"tag":427,"props":4770,"children":4771},{"style":439},[4772],{"type":398,"value":511},{"type":393,"tag":427,"props":4774,"children":4775},{"style":493},[4776],{"type":398,"value":4759},{"type":393,"tag":427,"props":4778,"children":4779},{"style":439},[4780],{"type":398,"value":511},{"type":393,"tag":427,"props":4782,"children":4783},{"style":493},[4784],{"type":398,"value":4768},{"type":393,"tag":427,"props":4786,"children":4787},{"style":439},[4788],{"type":398,"value":511},{"type":393,"tag":427,"props":4790,"children":4791},{"style":493},[4792],{"type":398,"value":4759},{"type":393,"tag":427,"props":4794,"children":4795},{"style":439},[4796],{"type":398,"value":553},{"type":393,"tag":427,"props":4798,"children":4799},{"class":429,"line":63},[4800,4804,4808,4812,4816,4820,4824,4828,4832,4836,4840,4844],{"type":393,"tag":427,"props":4801,"children":4802},{"style":493},[4803],{"type":398,"value":623},{"type":393,"tag":427,"props":4805,"children":4806},{"style":439},[4807],{"type":398,"value":501},{"type":393,"tag":427,"props":4809,"children":4810},{"style":493},[4811],{"type":398,"value":632},{"type":393,"tag":427,"props":4813,"children":4814},{"style":439},[4815],{"type":398,"value":511},{"type":393,"tag":427,"props":4817,"children":4818},{"style":493},[4819],{"type":398,"value":632},{"type":393,"tag":427,"props":4821,"children":4822},{"style":439},[4823],{"type":398,"value":511},{"type":393,"tag":427,"props":4825,"children":4826},{"style":493},[4827],{"type":398,"value":665},{"type":393,"tag":427,"props":4829,"children":4830},{"style":439},[4831],{"type":398,"value":511},{"type":393,"tag":427,"props":4833,"children":4834},{"style":493},[4835],{"type":398,"value":665},{"type":393,"tag":427,"props":4837,"children":4838},{"style":439},[4839],{"type":398,"value":511},{"type":393,"tag":427,"props":4841,"children":4842},{"style":493},[4843],{"type":398,"value":632},{"type":393,"tag":427,"props":4845,"children":4846},{"style":439},[4847],{"type":398,"value":553},{"type":393,"tag":427,"props":4849,"children":4850},{"class":429,"line":72},[4851,4855,4859,4864,4868,4873,4877,4882,4886,4891,4895,4900],{"type":393,"tag":427,"props":4852,"children":4853},{"style":493},[4854],{"type":398,"value":685},{"type":393,"tag":427,"props":4856,"children":4857},{"style":439},[4858],{"type":398,"value":501},{"type":393,"tag":427,"props":4860,"children":4861},{"style":692},[4862],{"type":398,"value":4863},"120000",{"type":393,"tag":427,"props":4865,"children":4866},{"style":439},[4867],{"type":398,"value":511},{"type":393,"tag":427,"props":4869,"children":4870},{"style":692},[4871],{"type":398,"value":4872},"95000",{"type":393,"tag":427,"props":4874,"children":4875},{"style":439},[4876],{"type":398,"value":511},{"type":393,"tag":427,"props":4878,"children":4879},{"style":692},[4880],{"type":398,"value":4881},"135000",{"type":393,"tag":427,"props":4883,"children":4884},{"style":439},[4885],{"type":398,"value":511},{"type":393,"tag":427,"props":4887,"children":4888},{"style":692},[4889],{"type":398,"value":4890},"110000",{"type":393,"tag":427,"props":4892,"children":4893},{"style":439},[4894],{"type":398,"value":511},{"type":393,"tag":427,"props":4896,"children":4897},{"style":692},[4898],{"type":398,"value":4899},"115000",{"type":393,"tag":427,"props":4901,"children":4902},{"style":439},[4903],{"type":398,"value":553},{"type":393,"tag":427,"props":4905,"children":4906},{"class":429,"line":83},[4907,4912,4916,4921,4925,4930,4934,4939,4943,4948,4952,4956],{"type":393,"tag":427,"props":4908,"children":4909},{"style":493},[4910],{"type":398,"value":4911},"    'target'",{"type":393,"tag":427,"props":4913,"children":4914},{"style":439},[4915],{"type":398,"value":501},{"type":393,"tag":427,"props":4917,"children":4918},{"style":692},[4919],{"type":398,"value":4920},"100000",{"type":393,"tag":427,"props":4922,"children":4923},{"style":439},[4924],{"type":398,"value":511},{"type":393,"tag":427,"props":4926,"children":4927},{"style":692},[4928],{"type":398,"value":4929},"90000",{"type":393,"tag":427,"props":4931,"children":4932},{"style":439},[4933],{"type":398,"value":511},{"type":393,"tag":427,"props":4935,"children":4936},{"style":692},[4937],{"type":398,"value":4938},"130000",{"type":393,"tag":427,"props":4940,"children":4941},{"style":439},[4942],{"type":398,"value":511},{"type":393,"tag":427,"props":4944,"children":4945},{"style":692},[4946],{"type":398,"value":4947},"105000",{"type":393,"tag":427,"props":4949,"children":4950},{"style":439},[4951],{"type":398,"value":511},{"type":393,"tag":427,"props":4953,"children":4954},{"style":692},[4955],{"type":398,"value":4890},{"type":393,"tag":427,"props":4957,"children":4958},{"style":439},[4959],{"type":398,"value":745},{"type":393,"tag":427,"props":4961,"children":4962},{"class":429,"line":92},[4963],{"type":393,"tag":427,"props":4964,"children":4965},{"style":439},[4966],{"type":398,"value":753},{"type":393,"tag":427,"props":4968,"children":4969},{"class":429,"line":101},[4970],{"type":393,"tag":427,"props":4971,"children":4972},{"emptyLinePlaceholder":12},[4973],{"type":398,"value":460},{"type":393,"tag":427,"props":4975,"children":4976},{"class":429,"line":110},[4977,4981,4985,4990],{"type":393,"tag":427,"props":4978,"children":4979},{"style":692},[4980],{"type":398,"value":768},{"type":393,"tag":427,"props":4982,"children":4983},{"style":439},[4984],{"type":398,"value":773},{"type":393,"tag":427,"props":4986,"children":4987},{"style":493},[4988],{"type":398,"value":4989},"\"Performance data:\"",{"type":393,"tag":427,"props":4991,"children":4992},{"style":439},[4993],{"type":398,"value":783},{"type":393,"tag":427,"props":4995,"children":4996},{"class":429,"line":121},[4997,5001],{"type":393,"tag":427,"props":4998,"children":4999},{"style":692},[5000],{"type":398,"value":768},{"type":393,"tag":427,"props":5002,"children":5003},{"style":439},[5004],{"type":398,"value":5005},"(performance)\n",{"type":393,"tag":427,"props":5007,"children":5008},{"class":429,"line":130},[5009,5013],{"type":393,"tag":427,"props":5010,"children":5011},{"style":692},[5012],{"type":398,"value":768},{"type":393,"tag":427,"props":5014,"children":5015},{"style":439},[5016],{"type":398,"value":807},{"type":393,"tag":427,"props":5018,"children":5019},{"class":429,"line":139},[5020],{"type":393,"tag":427,"props":5021,"children":5022},{"emptyLinePlaceholder":12},[5023],{"type":398,"value":460},{"type":393,"tag":427,"props":5025,"children":5026},{"class":429,"line":148},[5027],{"type":393,"tag":427,"props":5028,"children":5029},{"style":466},[5030],{"type":398,"value":5031},"# Formatted pivot table\n",{"type":393,"tag":427,"props":5033,"children":5034},{"class":429,"line":159},[5035,5040,5044],{"type":393,"tag":427,"props":5036,"children":5037},{"style":439},[5038],{"type":398,"value":5039},"formatted_pivot ",{"type":393,"tag":427,"props":5041,"children":5042},{"style":433},[5043],{"type":398,"value":482},{"type":393,"tag":427,"props":5045,"children":5046},{"style":439},[5047],{"type":398,"value":5048}," performance.pivot_table(\n",{"type":393,"tag":427,"props":5050,"children":5051},{"class":429,"line":168},[5052,5056,5060,5064,5068,5072,5077],{"type":393,"tag":427,"props":5053,"children":5054},{"style":845},[5055],{"type":398,"value":848},{"type":393,"tag":427,"props":5057,"children":5058},{"style":433},[5059],{"type":398,"value":482},{"type":393,"tag":427,"props":5061,"children":5062},{"style":439},[5063],{"type":398,"value":3924},{"type":393,"tag":427,"props":5065,"children":5066},{"style":493},[5067],{"type":398,"value":857},{"type":393,"tag":427,"props":5069,"children":5070},{"style":439},[5071],{"type":398,"value":511},{"type":393,"tag":427,"props":5073,"children":5074},{"style":493},[5075],{"type":398,"value":5076},"'target'",{"type":393,"tag":427,"props":5078,"children":5079},{"style":439},[5080],{"type":398,"value":553},{"type":393,"tag":427,"props":5082,"children":5083},{"class":429,"line":177},[5084,5088,5092,5097],{"type":393,"tag":427,"props":5085,"children":5086},{"style":845},[5087],{"type":398,"value":870},{"type":393,"tag":427,"props":5089,"children":5090},{"style":433},[5091],{"type":398,"value":482},{"type":393,"tag":427,"props":5093,"children":5094},{"style":493},[5095],{"type":398,"value":5096},"'team'",{"type":393,"tag":427,"props":5098,"children":5099},{"style":439},[5100],{"type":398,"value":862},{"type":393,"tag":427,"props":5102,"children":5103},{"class":429,"line":186},[5104,5108,5112,5116],{"type":393,"tag":427,"props":5105,"children":5106},{"style":845},[5107],{"type":398,"value":891},{"type":393,"tag":427,"props":5109,"children":5110},{"style":433},[5111],{"type":398,"value":482},{"type":393,"tag":427,"props":5113,"children":5114},{"style":493},[5115],{"type":398,"value":3937},{"type":393,"tag":427,"props":5117,"children":5118},{"style":439},[5119],{"type":398,"value":862},{"type":393,"tag":427,"props":5121,"children":5122},{"class":429,"line":197},[5123,5127,5131,5135],{"type":393,"tag":427,"props":5124,"children":5125},{"style":845},[5126],{"type":398,"value":912},{"type":393,"tag":427,"props":5128,"children":5129},{"style":433},[5130],{"type":398,"value":482},{"type":393,"tag":427,"props":5132,"children":5133},{"style":493},[5134],{"type":398,"value":3988},{"type":393,"tag":427,"props":5136,"children":5137},{"style":439},[5138],{"type":398,"value":862},{"type":393,"tag":427,"props":5140,"children":5141},{"class":429,"line":206},[5142,5146,5150,5154],{"type":393,"tag":427,"props":5143,"children":5144},{"style":845},[5145],{"type":398,"value":1951},{"type":393,"tag":427,"props":5147,"children":5148},{"style":433},[5149],{"type":398,"value":482},{"type":393,"tag":427,"props":5151,"children":5152},{"style":692},[5153],{"type":398,"value":1960},{"type":393,"tag":427,"props":5155,"children":5156},{"style":439},[5157],{"type":398,"value":862},{"type":393,"tag":427,"props":5159,"children":5160},{"class":429,"line":215},[5161,5165,5169,5173],{"type":393,"tag":427,"props":5162,"children":5163},{"style":845},[5164],{"type":398,"value":2741},{"type":393,"tag":427,"props":5166,"children":5167},{"style":433},[5168],{"type":398,"value":482},{"type":393,"tag":427,"props":5170,"children":5171},{"style":692},[5172],{"type":398,"value":2750},{"type":393,"tag":427,"props":5174,"children":5175},{"style":439},[5176],{"type":398,"value":862},{"type":393,"tag":427,"props":5178,"children":5179},{"class":429,"line":224},[5180,5184,5188],{"type":393,"tag":427,"props":5181,"children":5182},{"style":845},[5183],{"type":398,"value":2762},{"type":393,"tag":427,"props":5185,"children":5186},{"style":433},[5187],{"type":398,"value":482},{"type":393,"tag":427,"props":5189,"children":5190},{"style":493},[5191],{"type":398,"value":2771},{"type":393,"tag":427,"props":5193,"children":5194},{"class":429,"line":233},[5195],{"type":393,"tag":427,"props":5196,"children":5197},{"style":439},[5198],{"type":398,"value":783},{"type":393,"tag":427,"props":5200,"children":5201},{"class":429,"line":244},[5202],{"type":393,"tag":427,"props":5203,"children":5204},{"emptyLinePlaceholder":12},[5205],{"type":398,"value":460},{"type":393,"tag":427,"props":5207,"children":5208},{"class":429,"line":253},[5209],{"type":393,"tag":427,"props":5210,"children":5211},{"style":466},[5212],{"type":398,"value":5213},"# Round to thousands for readability\n",{"type":393,"tag":427,"props":5215,"children":5216},{"class":429,"line":262},[5217,5221,5225,5230,5235,5240,5245,5249,5254,5259],{"type":393,"tag":427,"props":5218,"children":5219},{"style":439},[5220],{"type":398,"value":5039},{"type":393,"tag":427,"props":5222,"children":5223},{"style":433},[5224],{"type":398,"value":482},{"type":393,"tag":427,"props":5226,"children":5227},{"style":439},[5228],{"type":398,"value":5229}," (formatted_pivot ",{"type":393,"tag":427,"props":5231,"children":5232},{"style":433},[5233],{"type":398,"value":5234},"/",{"type":393,"tag":427,"props":5236,"children":5237},{"style":692},[5238],{"type":398,"value":5239}," 1000",{"type":393,"tag":427,"props":5241,"children":5242},{"style":439},[5243],{"type":398,"value":5244},").round(",{"type":393,"tag":427,"props":5246,"children":5247},{"style":692},[5248],{"type":398,"value":1960},{"type":393,"tag":427,"props":5250,"children":5251},{"style":439},[5252],{"type":398,"value":5253},").astype(",{"type":393,"tag":427,"props":5255,"children":5256},{"style":692},[5257],{"type":398,"value":5258},"int",{"type":393,"tag":427,"props":5260,"children":5261},{"style":439},[5262],{"type":398,"value":783},{"type":393,"tag":427,"props":5264,"children":5265},{"class":429,"line":271},[5266],{"type":393,"tag":427,"props":5267,"children":5268},{"emptyLinePlaceholder":12},[5269],{"type":398,"value":460},{"type":393,"tag":427,"props":5271,"children":5272},{"class":429,"line":281},[5273,5277,5281,5286],{"type":393,"tag":427,"props":5274,"children":5275},{"style":692},[5276],{"type":398,"value":768},{"type":393,"tag":427,"props":5278,"children":5279},{"style":439},[5280],{"type":398,"value":773},{"type":393,"tag":427,"props":5282,"children":5283},{"style":493},[5284],{"type":398,"value":5285},"\"Revenue and targets by team and quarter (in thousands):\"",{"type":393,"tag":427,"props":5287,"children":5288},{"style":439},[5289],{"type":398,"value":783},{"type":393,"tag":427,"props":5291,"children":5292},{"class":429,"line":290},[5293,5297],{"type":393,"tag":427,"props":5294,"children":5295},{"style":692},[5296],{"type":398,"value":768},{"type":393,"tag":427,"props":5298,"children":5299},{"style":439},[5300],{"type":398,"value":5301},"(formatted_pivot)\n",{"type":393,"tag":962,"props":5303,"children":5305},{"id":5304},"real-world-applications",[5306],{"type":398,"value":5307},"🎯 Real-World Applications",{"type":393,"tag":974,"props":5309,"children":5312},{"emoji":5310,"title":5311,"type":2173},"💼","Business Use Cases",[5313,5321,5339,5347,5365,5373,5391,5399,5417],{"type":393,"tag":401,"props":5314,"children":5315},{},[5316],{"type":393,"tag":984,"props":5317,"children":5318},{},[5319],{"type":398,"value":5320},"Sales Analysis:",{"type":393,"tag":990,"props":5322,"children":5323},{},[5324,5329,5334],{"type":393,"tag":994,"props":5325,"children":5326},{},[5327],{"type":398,"value":5328},"Revenue by product, region, time period",{"type":393,"tag":994,"props":5330,"children":5331},{},[5332],{"type":398,"value":5333},"Performance vs targets by team",{"type":393,"tag":994,"props":5335,"children":5336},{},[5337],{"type":398,"value":5338},"Customer segments by demographics",{"type":393,"tag":401,"props":5340,"children":5341},{},[5342],{"type":393,"tag":984,"props":5343,"children":5344},{},[5345],{"type":398,"value":5346},"Marketing Analytics:",{"type":393,"tag":990,"props":5348,"children":5349},{},[5350,5355,5360],{"type":393,"tag":994,"props":5351,"children":5352},{},[5353],{"type":398,"value":5354},"Campaign performance by channel and audience",{"type":393,"tag":994,"props":5356,"children":5357},{},[5358],{"type":398,"value":5359},"Conversion rates by source and time",{"type":393,"tag":994,"props":5361,"children":5362},{},[5363],{"type":398,"value":5364},"Customer acquisition costs",{"type":393,"tag":401,"props":5366,"children":5367},{},[5368],{"type":393,"tag":984,"props":5369,"children":5370},{},[5371],{"type":398,"value":5372},"Operations:",{"type":393,"tag":990,"props":5374,"children":5375},{},[5376,5381,5386],{"type":393,"tag":994,"props":5377,"children":5378},{},[5379],{"type":398,"value":5380},"Inventory levels by location and category",{"type":393,"tag":994,"props":5382,"children":5383},{},[5384],{"type":398,"value":5385},"Quality metrics by department and shift",{"type":393,"tag":994,"props":5387,"children":5388},{},[5389],{"type":398,"value":5390},"Resource utilization by project and team",{"type":393,"tag":401,"props":5392,"children":5393},{},[5394],{"type":393,"tag":984,"props":5395,"children":5396},{},[5397],{"type":398,"value":5398},"Financial Reporting:",{"type":393,"tag":990,"props":5400,"children":5401},{},[5402,5407,5412],{"type":393,"tag":994,"props":5403,"children":5404},{},[5405],{"type":398,"value":5406},"Budget vs actual by department",{"type":393,"tag":994,"props":5408,"children":5409},{},[5410],{"type":398,"value":5411},"Expense analysis by category and period",{"type":393,"tag":994,"props":5413,"children":5414},{},[5415],{"type":398,"value":5416},"Profitability by product line",{"type":393,"tag":401,"props":5418,"children":5419},{},[5420,5425],{"type":393,"tag":984,"props":5421,"children":5422},{},[5423],{"type":398,"value":5424},"Remember:",{"type":398,"value":5426}," Pivot tables turn complex data into actionable insights!",{"type":393,"tag":962,"props":5428,"children":5430},{"id":5429},"practice-customer-analysis",[5431],{"type":398,"value":5432},"📝 Practice: Customer Analysis",{"type":393,"tag":401,"props":5434,"children":5435},{},[5436],{"type":398,"value":5437},"Let's practice with a realistic customer analysis:",{"type":393,"tag":412,"props":5439,"children":5440},{},[5441],{"type":393,"tag":416,"props":5442,"children":5444},{"code":5443,"language":419,"meta":6,"className":420,"style":6},"import pandas as pd\n\n# Customer purchase data\npurchases = pd.DataFrame({\n    'customer_segment': ['Premium', 'Standard', 'Premium', 'Basic', 'Standard'],\n    'product_category': ['Electronics', 'Books', 'Clothing', 'Books', 'Electronics'],\n    'quarter': ['Q1', 'Q1', 'Q2', 'Q2', 'Q1'],\n    'amount': [1200, 45, 300, 25, 150],\n    'satisfaction': [5, 4, 4, 3, 4]\n})\n\nprint(\"Customer purchases:\")\nprint(purchases)\nprint()\n\n# Analysis 1: Total spending by segment and category\nspending_analysis = purchases.pivot_table(\n    values='amount',\n    index='customer_segment',\n    columns='product_category',\n    aggfunc='sum',\n    fill_value=0\n)\nprint(\"Total spending by segment and category:\")\nprint(spending_analysis)\nprint()\n\n# Analysis 2: Average satisfaction\nsatisfaction_analysis = purchases.pivot_table(\n    values='satisfaction',\n    index='customer_segment',\n    columns='quarter',\n    aggfunc='mean'\n)\nprint(\"Average satisfaction by segment and quarter:\")\nprint(satisfaction_analysis.round(1))\n",[5445],{"type":393,"tag":423,"props":5446,"children":5447},{"__ignoreMap":6},[5448,5467,5474,5482,5498,5553,5607,5658,5715,5766,5773,5780,5800,5812,5823,5830,5838,5855,5875,5895,5915,5934,5949,5956,5976,5988,5999,6006,6014,6030,6049,6068,6087,6102,6109,6129],{"type":393,"tag":427,"props":5449,"children":5450},{"class":429,"line":11},[5451,5455,5459,5463],{"type":393,"tag":427,"props":5452,"children":5453},{"style":433},[5454],{"type":398,"value":436},{"type":393,"tag":427,"props":5456,"children":5457},{"style":439},[5458],{"type":398,"value":442},{"type":393,"tag":427,"props":5460,"children":5461},{"style":433},[5462],{"type":398,"value":447},{"type":393,"tag":427,"props":5464,"children":5465},{"style":439},[5466],{"type":398,"value":452},{"type":393,"tag":427,"props":5468,"children":5469},{"class":429,"line":27},[5470],{"type":393,"tag":427,"props":5471,"children":5472},{"emptyLinePlaceholder":12},[5473],{"type":398,"value":460},{"type":393,"tag":427,"props":5475,"children":5476},{"class":429,"line":36},[5477],{"type":393,"tag":427,"props":5478,"children":5479},{"style":466},[5480],{"type":398,"value":5481},"# Customer purchase data\n",{"type":393,"tag":427,"props":5483,"children":5484},{"class":429,"line":45},[5485,5490,5494],{"type":393,"tag":427,"props":5486,"children":5487},{"style":439},[5488],{"type":398,"value":5489},"purchases ",{"type":393,"tag":427,"props":5491,"children":5492},{"style":433},[5493],{"type":398,"value":482},{"type":393,"tag":427,"props":5495,"children":5496},{"style":439},[5497],{"type":398,"value":487},{"type":393,"tag":427,"props":5499,"children":5500},{"class":429,"line":54},[5501,5506,5510,5515,5519,5524,5528,5532,5536,5541,5545,5549],{"type":393,"tag":427,"props":5502,"children":5503},{"style":493},[5504],{"type":398,"value":5505},"    'customer_segment'",{"type":393,"tag":427,"props":5507,"children":5508},{"style":439},[5509],{"type":398,"value":501},{"type":393,"tag":427,"props":5511,"children":5512},{"style":493},[5513],{"type":398,"value":5514},"'Premium'",{"type":393,"tag":427,"props":5516,"children":5517},{"style":439},[5518],{"type":398,"value":511},{"type":393,"tag":427,"props":5520,"children":5521},{"style":493},[5522],{"type":398,"value":5523},"'Standard'",{"type":393,"tag":427,"props":5525,"children":5526},{"style":439},[5527],{"type":398,"value":511},{"type":393,"tag":427,"props":5529,"children":5530},{"style":493},[5531],{"type":398,"value":5514},{"type":393,"tag":427,"props":5533,"children":5534},{"style":439},[5535],{"type":398,"value":511},{"type":393,"tag":427,"props":5537,"children":5538},{"style":493},[5539],{"type":398,"value":5540},"'Basic'",{"type":393,"tag":427,"props":5542,"children":5543},{"style":439},[5544],{"type":398,"value":511},{"type":393,"tag":427,"props":5546,"children":5547},{"style":493},[5548],{"type":398,"value":5523},{"type":393,"tag":427,"props":5550,"children":5551},{"style":439},[5552],{"type":398,"value":553},{"type":393,"tag":427,"props":5554,"children":5555},{"class":429,"line":63},[5556,5561,5565,5570,5574,5578,5582,5587,5591,5595,5599,5603],{"type":393,"tag":427,"props":5557,"children":5558},{"style":493},[5559],{"type":398,"value":5560},"    'product_category'",{"type":393,"tag":427,"props":5562,"children":5563},{"style":439},[5564],{"type":398,"value":501},{"type":393,"tag":427,"props":5566,"children":5567},{"style":493},[5568],{"type":398,"value":5569},"'Electronics'",{"type":393,"tag":427,"props":5571,"children":5572},{"style":439},[5573],{"type":398,"value":511},{"type":393,"tag":427,"props":5575,"children":5576},{"style":493},[5577],{"type":398,"value":2963},{"type":393,"tag":427,"props":5579,"children":5580},{"style":439},[5581],{"type":398,"value":511},{"type":393,"tag":427,"props":5583,"children":5584},{"style":493},[5585],{"type":398,"value":5586},"'Clothing'",{"type":393,"tag":427,"props":5588,"children":5589},{"style":439},[5590],{"type":398,"value":511},{"type":393,"tag":427,"props":5592,"children":5593},{"style":493},[5594],{"type":398,"value":2963},{"type":393,"tag":427,"props":5596,"children":5597},{"style":439},[5598],{"type":398,"value":511},{"type":393,"tag":427,"props":5600,"children":5601},{"style":493},[5602],{"type":398,"value":5569},{"type":393,"tag":427,"props":5604,"children":5605},{"style":439},[5606],{"type":398,"value":553},{"type":393,"tag":427,"props":5608,"children":5609},{"class":429,"line":72},[5610,5614,5618,5622,5626,5630,5634,5638,5642,5646,5650,5654],{"type":393,"tag":427,"props":5611,"children":5612},{"style":493},[5613],{"type":398,"value":623},{"type":393,"tag":427,"props":5615,"children":5616},{"style":439},[5617],{"type":398,"value":501},{"type":393,"tag":427,"props":5619,"children":5620},{"style":493},[5621],{"type":398,"value":632},{"type":393,"tag":427,"props":5623,"children":5624},{"style":439},[5625],{"type":398,"value":511},{"type":393,"tag":427,"props":5627,"children":5628},{"style":493},[5629],{"type":398,"value":632},{"type":393,"tag":427,"props":5631,"children":5632},{"style":439},[5633],{"type":398,"value":511},{"type":393,"tag":427,"props":5635,"children":5636},{"style":493},[5637],{"type":398,"value":665},{"type":393,"tag":427,"props":5639,"children":5640},{"style":439},[5641],{"type":398,"value":511},{"type":393,"tag":427,"props":5643,"children":5644},{"style":493},[5645],{"type":398,"value":665},{"type":393,"tag":427,"props":5647,"children":5648},{"style":439},[5649],{"type":398,"value":511},{"type":393,"tag":427,"props":5651,"children":5652},{"style":493},[5653],{"type":398,"value":632},{"type":393,"tag":427,"props":5655,"children":5656},{"style":439},[5657],{"type":398,"value":553},{"type":393,"tag":427,"props":5659,"children":5660},{"class":429,"line":83},[5661,5666,5670,5675,5679,5684,5688,5693,5697,5702,5706,5711],{"type":393,"tag":427,"props":5662,"children":5663},{"style":493},[5664],{"type":398,"value":5665},"    'amount'",{"type":393,"tag":427,"props":5667,"children":5668},{"style":439},[5669],{"type":398,"value":501},{"type":393,"tag":427,"props":5671,"children":5672},{"style":692},[5673],{"type":398,"value":5674},"1200",{"type":393,"tag":427,"props":5676,"children":5677},{"style":439},[5678],{"type":398,"value":511},{"type":393,"tag":427,"props":5680,"children":5681},{"style":692},[5682],{"type":398,"value":5683},"45",{"type":393,"tag":427,"props":5685,"children":5686},{"style":439},[5687],{"type":398,"value":511},{"type":393,"tag":427,"props":5689,"children":5690},{"style":692},[5691],{"type":398,"value":5692},"300",{"type":393,"tag":427,"props":5694,"children":5695},{"style":439},[5696],{"type":398,"value":511},{"type":393,"tag":427,"props":5698,"children":5699},{"style":692},[5700],{"type":398,"value":5701},"25",{"type":393,"tag":427,"props":5703,"children":5704},{"style":439},[5705],{"type":398,"value":511},{"type":393,"tag":427,"props":5707,"children":5708},{"style":692},[5709],{"type":398,"value":5710},"150",{"type":393,"tag":427,"props":5712,"children":5713},{"style":439},[5714],{"type":398,"value":553},{"type":393,"tag":427,"props":5716,"children":5717},{"class":429,"line":92},[5718,5722,5726,5730,5734,5738,5742,5746,5750,5754,5758,5762],{"type":393,"tag":427,"props":5719,"children":5720},{"style":493},[5721],{"type":398,"value":2384},{"type":393,"tag":427,"props":5723,"children":5724},{"style":439},[5725],{"type":398,"value":501},{"type":393,"tag":427,"props":5727,"children":5728},{"style":692},[5729],{"type":398,"value":1682},{"type":393,"tag":427,"props":5731,"children":5732},{"style":439},[5733],{"type":398,"value":511},{"type":393,"tag":427,"props":5735,"children":5736},{"style":692},[5737],{"type":398,"value":1691},{"type":393,"tag":427,"props":5739,"children":5740},{"style":439},[5741],{"type":398,"value":511},{"type":393,"tag":427,"props":5743,"children":5744},{"style":692},[5745],{"type":398,"value":1691},{"type":393,"tag":427,"props":5747,"children":5748},{"style":439},[5749],{"type":398,"value":511},{"type":393,"tag":427,"props":5751,"children":5752},{"style":692},[5753],{"type":398,"value":1716},{"type":393,"tag":427,"props":5755,"children":5756},{"style":439},[5757],{"type":398,"value":511},{"type":393,"tag":427,"props":5759,"children":5760},{"style":692},[5761],{"type":398,"value":1691},{"type":393,"tag":427,"props":5763,"children":5764},{"style":439},[5765],{"type":398,"value":745},{"type":393,"tag":427,"props":5767,"children":5768},{"class":429,"line":101},[5769],{"type":393,"tag":427,"props":5770,"children":5771},{"style":439},[5772],{"type":398,"value":753},{"type":393,"tag":427,"props":5774,"children":5775},{"class":429,"line":110},[5776],{"type":393,"tag":427,"props":5777,"children":5778},{"emptyLinePlaceholder":12},[5779],{"type":398,"value":460},{"type":393,"tag":427,"props":5781,"children":5782},{"class":429,"line":121},[5783,5787,5791,5796],{"type":393,"tag":427,"props":5784,"children":5785},{"style":692},[5786],{"type":398,"value":768},{"type":393,"tag":427,"props":5788,"children":5789},{"style":439},[5790],{"type":398,"value":773},{"type":393,"tag":427,"props":5792,"children":5793},{"style":493},[5794],{"type":398,"value":5795},"\"Customer purchases:\"",{"type":393,"tag":427,"props":5797,"children":5798},{"style":439},[5799],{"type":398,"value":783},{"type":393,"tag":427,"props":5801,"children":5802},{"class":429,"line":130},[5803,5807],{"type":393,"tag":427,"props":5804,"children":5805},{"style":692},[5806],{"type":398,"value":768},{"type":393,"tag":427,"props":5808,"children":5809},{"style":439},[5810],{"type":398,"value":5811},"(purchases)\n",{"type":393,"tag":427,"props":5813,"children":5814},{"class":429,"line":139},[5815,5819],{"type":393,"tag":427,"props":5816,"children":5817},{"style":692},[5818],{"type":398,"value":768},{"type":393,"tag":427,"props":5820,"children":5821},{"style":439},[5822],{"type":398,"value":807},{"type":393,"tag":427,"props":5824,"children":5825},{"class":429,"line":148},[5826],{"type":393,"tag":427,"props":5827,"children":5828},{"emptyLinePlaceholder":12},[5829],{"type":398,"value":460},{"type":393,"tag":427,"props":5831,"children":5832},{"class":429,"line":159},[5833],{"type":393,"tag":427,"props":5834,"children":5835},{"style":466},[5836],{"type":398,"value":5837},"# Analysis 1: Total spending by segment and category\n",{"type":393,"tag":427,"props":5839,"children":5840},{"class":429,"line":168},[5841,5846,5850],{"type":393,"tag":427,"props":5842,"children":5843},{"style":439},[5844],{"type":398,"value":5845},"spending_analysis ",{"type":393,"tag":427,"props":5847,"children":5848},{"style":433},[5849],{"type":398,"value":482},{"type":393,"tag":427,"props":5851,"children":5852},{"style":439},[5853],{"type":398,"value":5854}," purchases.pivot_table(\n",{"type":393,"tag":427,"props":5856,"children":5857},{"class":429,"line":177},[5858,5862,5866,5871],{"type":393,"tag":427,"props":5859,"children":5860},{"style":845},[5861],{"type":398,"value":848},{"type":393,"tag":427,"props":5863,"children":5864},{"style":433},[5865],{"type":398,"value":482},{"type":393,"tag":427,"props":5867,"children":5868},{"style":493},[5869],{"type":398,"value":5870},"'amount'",{"type":393,"tag":427,"props":5872,"children":5873},{"style":439},[5874],{"type":398,"value":862},{"type":393,"tag":427,"props":5876,"children":5877},{"class":429,"line":186},[5878,5882,5886,5891],{"type":393,"tag":427,"props":5879,"children":5880},{"style":845},[5881],{"type":398,"value":870},{"type":393,"tag":427,"props":5883,"children":5884},{"style":433},[5885],{"type":398,"value":482},{"type":393,"tag":427,"props":5887,"children":5888},{"style":493},[5889],{"type":398,"value":5890},"'customer_segment'",{"type":393,"tag":427,"props":5892,"children":5893},{"style":439},[5894],{"type":398,"value":862},{"type":393,"tag":427,"props":5896,"children":5897},{"class":429,"line":197},[5898,5902,5906,5911],{"type":393,"tag":427,"props":5899,"children":5900},{"style":845},[5901],{"type":398,"value":891},{"type":393,"tag":427,"props":5903,"children":5904},{"style":433},[5905],{"type":398,"value":482},{"type":393,"tag":427,"props":5907,"children":5908},{"style":493},[5909],{"type":398,"value":5910},"'product_category'",{"type":393,"tag":427,"props":5912,"children":5913},{"style":439},[5914],{"type":398,"value":862},{"type":393,"tag":427,"props":5916,"children":5917},{"class":429,"line":206},[5918,5922,5926,5930],{"type":393,"tag":427,"props":5919,"children":5920},{"style":845},[5921],{"type":398,"value":912},{"type":393,"tag":427,"props":5923,"children":5924},{"style":433},[5925],{"type":398,"value":482},{"type":393,"tag":427,"props":5927,"children":5928},{"style":493},[5929],{"type":398,"value":3988},{"type":393,"tag":427,"props":5931,"children":5932},{"style":439},[5933],{"type":398,"value":862},{"type":393,"tag":427,"props":5935,"children":5936},{"class":429,"line":215},[5937,5941,5945],{"type":393,"tag":427,"props":5938,"children":5939},{"style":845},[5940],{"type":398,"value":1951},{"type":393,"tag":427,"props":5942,"children":5943},{"style":433},[5944],{"type":398,"value":482},{"type":393,"tag":427,"props":5946,"children":5947},{"style":692},[5948],{"type":398,"value":4008},{"type":393,"tag":427,"props":5950,"children":5951},{"class":429,"line":224},[5952],{"type":393,"tag":427,"props":5953,"children":5954},{"style":439},[5955],{"type":398,"value":783},{"type":393,"tag":427,"props":5957,"children":5958},{"class":429,"line":233},[5959,5963,5967,5972],{"type":393,"tag":427,"props":5960,"children":5961},{"style":692},[5962],{"type":398,"value":768},{"type":393,"tag":427,"props":5964,"children":5965},{"style":439},[5966],{"type":398,"value":773},{"type":393,"tag":427,"props":5968,"children":5969},{"style":493},[5970],{"type":398,"value":5971},"\"Total spending by segment and category:\"",{"type":393,"tag":427,"props":5973,"children":5974},{"style":439},[5975],{"type":398,"value":783},{"type":393,"tag":427,"props":5977,"children":5978},{"class":429,"line":244},[5979,5983],{"type":393,"tag":427,"props":5980,"children":5981},{"style":692},[5982],{"type":398,"value":768},{"type":393,"tag":427,"props":5984,"children":5985},{"style":439},[5986],{"type":398,"value":5987},"(spending_analysis)\n",{"type":393,"tag":427,"props":5989,"children":5990},{"class":429,"line":253},[5991,5995],{"type":393,"tag":427,"props":5992,"children":5993},{"style":692},[5994],{"type":398,"value":768},{"type":393,"tag":427,"props":5996,"children":5997},{"style":439},[5998],{"type":398,"value":807},{"type":393,"tag":427,"props":6000,"children":6001},{"class":429,"line":262},[6002],{"type":393,"tag":427,"props":6003,"children":6004},{"emptyLinePlaceholder":12},[6005],{"type":398,"value":460},{"type":393,"tag":427,"props":6007,"children":6008},{"class":429,"line":271},[6009],{"type":393,"tag":427,"props":6010,"children":6011},{"style":466},[6012],{"type":398,"value":6013},"# Analysis 2: Average satisfaction\n",{"type":393,"tag":427,"props":6015,"children":6016},{"class":429,"line":281},[6017,6022,6026],{"type":393,"tag":427,"props":6018,"children":6019},{"style":439},[6020],{"type":398,"value":6021},"satisfaction_analysis ",{"type":393,"tag":427,"props":6023,"children":6024},{"style":433},[6025],{"type":398,"value":482},{"type":393,"tag":427,"props":6027,"children":6028},{"style":439},[6029],{"type":398,"value":5854},{"type":393,"tag":427,"props":6031,"children":6032},{"class":429,"line":290},[6033,6037,6041,6045],{"type":393,"tag":427,"props":6034,"children":6035},{"style":845},[6036],{"type":398,"value":848},{"type":393,"tag":427,"props":6038,"children":6039},{"style":433},[6040],{"type":398,"value":482},{"type":393,"tag":427,"props":6042,"children":6043},{"style":493},[6044],{"type":398,"value":2618},{"type":393,"tag":427,"props":6046,"children":6047},{"style":439},[6048],{"type":398,"value":862},{"type":393,"tag":427,"props":6050,"children":6051},{"class":429,"line":299},[6052,6056,6060,6064],{"type":393,"tag":427,"props":6053,"children":6054},{"style":845},[6055],{"type":398,"value":870},{"type":393,"tag":427,"props":6057,"children":6058},{"style":433},[6059],{"type":398,"value":482},{"type":393,"tag":427,"props":6061,"children":6062},{"style":493},[6063],{"type":398,"value":5890},{"type":393,"tag":427,"props":6065,"children":6066},{"style":439},[6067],{"type":398,"value":862},{"type":393,"tag":427,"props":6069,"children":6070},{"class":429,"line":308},[6071,6075,6079,6083],{"type":393,"tag":427,"props":6072,"children":6073},{"style":845},[6074],{"type":398,"value":891},{"type":393,"tag":427,"props":6076,"children":6077},{"style":433},[6078],{"type":398,"value":482},{"type":393,"tag":427,"props":6080,"children":6081},{"style":493},[6082],{"type":398,"value":3937},{"type":393,"tag":427,"props":6084,"children":6085},{"style":439},[6086],{"type":398,"value":862},{"type":393,"tag":427,"props":6088,"children":6089},{"class":429,"line":318},[6090,6094,6098],{"type":393,"tag":427,"props":6091,"children":6092},{"style":845},[6093],{"type":398,"value":912},{"type":393,"tag":427,"props":6095,"children":6096},{"style":433},[6097],{"type":398,"value":482},{"type":393,"tag":427,"props":6099,"children":6100},{"style":493},[6101],{"type":398,"value":1507},{"type":393,"tag":427,"props":6103,"children":6104},{"class":429,"line":327},[6105],{"type":393,"tag":427,"props":6106,"children":6107},{"style":439},[6108],{"type":398,"value":783},{"type":393,"tag":427,"props":6110,"children":6111},{"class":429,"line":336},[6112,6116,6120,6125],{"type":393,"tag":427,"props":6113,"children":6114},{"style":692},[6115],{"type":398,"value":768},{"type":393,"tag":427,"props":6117,"children":6118},{"style":439},[6119],{"type":398,"value":773},{"type":393,"tag":427,"props":6121,"children":6122},{"style":493},[6123],{"type":398,"value":6124},"\"Average satisfaction by segment and quarter:\"",{"type":393,"tag":427,"props":6126,"children":6127},{"style":439},[6128],{"type":398,"value":783},{"type":393,"tag":427,"props":6130,"children":6131},{"class":429,"line":346},[6132,6136,6141,6145],{"type":393,"tag":427,"props":6133,"children":6134},{"style":692},[6135],{"type":398,"value":768},{"type":393,"tag":427,"props":6137,"children":6138},{"style":439},[6139],{"type":398,"value":6140},"(satisfaction_analysis.round(",{"type":393,"tag":427,"props":6142,"children":6143},{"style":692},[6144],{"type":398,"value":3265},{"type":393,"tag":427,"props":6146,"children":6147},{"style":439},[6148],{"type":398,"value":3270},{"type":393,"tag":962,"props":6150,"children":6152},{"id":6151},"key-takeaways",[6153],{"type":398,"value":6154},"🎯 Key Takeaways",{"type":393,"tag":974,"props":6156,"children":6159},{"emoji":6157,"title":6158,"type":2173},"📚","Pivot Tables & Crosstab Summary",[6160,6168,6209,6217,6253,6261,6283,6291,6314],{"type":393,"tag":401,"props":6161,"children":6162},{},[6163],{"type":393,"tag":984,"props":6164,"children":6165},{},[6166],{"type":398,"value":6167},"Pivot Tables:",{"type":393,"tag":990,"props":6169,"children":6170},{},[6171,6182,6187,6198],{"type":393,"tag":994,"props":6172,"children":6173},{},[6174,6180],{"type":393,"tag":423,"props":6175,"children":6177},{"className":6176},[],[6178],{"type":398,"value":6179},"pd.pivot_table()",{"type":398,"value":6181}," for numerical summaries",{"type":393,"tag":994,"props":6183,"children":6184},{},[6185],{"type":398,"value":6186},"Specify: values, index, columns, aggfunc",{"type":393,"tag":994,"props":6188,"children":6189},{},[6190,6191,6196],{"type":398,"value":4595},{"type":393,"tag":423,"props":6192,"children":6194},{"className":6193},[],[6195],{"type":398,"value":4601},{"type":398,"value":6197}," for clean results",{"type":393,"tag":994,"props":6199,"children":6200},{},[6201,6203,6208],{"type":398,"value":6202},"Add ",{"type":393,"tag":423,"props":6204,"children":6206},{"className":6205},[],[6207],{"type":398,"value":4623},{"type":398,"value":4625},{"type":393,"tag":401,"props":6210,"children":6211},{},[6212],{"type":393,"tag":984,"props":6213,"children":6214},{},[6215],{"type":398,"value":6216},"Cross Tabulation:",{"type":393,"tag":990,"props":6218,"children":6219},{},[6220,6231,6236,6248],{"type":393,"tag":994,"props":6221,"children":6222},{},[6223,6229],{"type":393,"tag":423,"props":6224,"children":6226},{"className":6225},[],[6227],{"type":398,"value":6228},"pd.crosstab()",{"type":398,"value":6230}," for categorical analysis",{"type":393,"tag":994,"props":6232,"children":6233},{},[6234],{"type":398,"value":6235},"Perfect for frequency analysis",{"type":393,"tag":994,"props":6237,"children":6238},{},[6239,6240,6246],{"type":398,"value":4595},{"type":393,"tag":423,"props":6241,"children":6243},{"className":6242},[],[6244],{"type":398,"value":6245},"normalize",{"type":398,"value":6247}," for percentages",{"type":393,"tag":994,"props":6249,"children":6250},{},[6251],{"type":398,"value":6252},"Great for understanding relationships",{"type":393,"tag":401,"props":6254,"children":6255},{},[6256],{"type":393,"tag":984,"props":6257,"children":6258},{},[6259],{"type":398,"value":6260},"Best Practices:",{"type":393,"tag":990,"props":6262,"children":6263},{},[6264,6269,6274,6279],{"type":393,"tag":994,"props":6265,"children":6266},{},[6267],{"type":398,"value":6268},"Choose appropriate aggregation functions",{"type":393,"tag":994,"props":6270,"children":6271},{},[6272],{"type":398,"value":6273},"Format results for readability",{"type":393,"tag":994,"props":6275,"children":6276},{},[6277],{"type":398,"value":6278},"Use meaningful names",{"type":393,"tag":994,"props":6280,"children":6281},{},[6282],{"type":398,"value":4672},{"type":393,"tag":401,"props":6284,"children":6285},{},[6286],{"type":393,"tag":984,"props":6287,"children":6288},{},[6289],{"type":398,"value":6290},"Common Patterns:",{"type":393,"tag":990,"props":6292,"children":6293},{},[6294,6299,6304,6309],{"type":393,"tag":994,"props":6295,"children":6296},{},[6297],{"type":398,"value":6298},"Sales by region and product",{"type":393,"tag":994,"props":6300,"children":6301},{},[6302],{"type":398,"value":6303},"Performance by team and time period",{"type":393,"tag":994,"props":6305,"children":6306},{},[6307],{"type":398,"value":6308},"Customer analysis by segment",{"type":393,"tag":994,"props":6310,"children":6311},{},[6312],{"type":398,"value":6313},"Quality metrics by department",{"type":393,"tag":401,"props":6315,"children":6316},{},[6317,6321],{"type":393,"tag":984,"props":6318,"children":6319},{},[6320],{"type":398,"value":5424},{"type":398,"value":6322}," Pivot tables transform rows into insights!",{"type":393,"tag":962,"props":6324,"children":6326},{"id":6325},"whats-next",[6327],{"type":398,"value":6328},"🚀 What's Next?",{"type":393,"tag":401,"props":6330,"children":6331},{},[6332],{"type":398,"value":6333},"Excellent! You now know how to create powerful summary tables with pivot tables and cross-tabulation. Next, let's learn about combining data from different sources with concatenation and merging.",{"type":393,"tag":401,"props":6335,"children":6336},{},[6337,6342,6344],{"type":393,"tag":984,"props":6338,"children":6339},{},[6340],{"type":398,"value":6341},"Continue to",{"type":398,"value":6343},": ",{"type":393,"tag":6345,"props":6346,"children":6347},"a",{"href":314},[6348],{"type":398,"value":315},{"type":393,"tag":401,"props":6350,"children":6351},{},[6352],{"type":398,"value":6353},"Keep pivoting! 📋📊",{"type":393,"tag":6355,"props":6356,"children":6357},"style",{},[6358],{"type":398,"value":6359},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .app-dark-mode .shiki span {color: var(--shiki-app-dark-mode);background: var(--shiki-app-dark-mode-bg);font-style: var(--shiki-app-dark-mode-font-style);font-weight: var(--shiki-app-dark-mode-font-weight);text-decoration: var(--shiki-app-dark-mode-text-decoration);}html.app-dark-mode .shiki span {color: var(--shiki-app-dark-mode);background: var(--shiki-app-dark-mode-bg);font-style: var(--shiki-app-dark-mode-font-style);font-weight: var(--shiki-app-dark-mode-font-weight);text-decoration: var(--shiki-app-dark-mode-text-decoration);}",{"title":6,"searchDepth":36,"depth":36,"links":6361},[6362,6363,6366,6369,6370,6371,6372,6373,6374,6375],{"id":964,"depth":27,"text":967},{"id":1083,"depth":27,"text":1086,"children":6364},[6365],{"id":1550,"depth":36,"text":1553},{"id":2160,"depth":27,"text":2163,"children":6367},[6368],{"id":2813,"depth":36,"text":2816},{"id":3428,"depth":27,"text":3431},{"id":4050,"depth":27,"text":4053},{"id":4566,"depth":27,"text":4569},{"id":5304,"depth":27,"text":5307},{"id":5429,"depth":27,"text":5432},{"id":6151,"depth":27,"text":6154},{"id":6325,"depth":27,"text":6328},1782373726325]