{ "cells": [ { "cell_type": "markdown", "id": "650e0648", "metadata": {}, "source": [ "---\n", "title: \"Statistical Analysis with Python\"\n", "description: \"Learn statistical analysis using Python's scipy and pandas libraries with real survey data\"\n", "date: 2025-01-27\n", "lastmod: 2025-01-27\n", "author: \"Zer0-Mistakes Team\"\n", "layout: notebook\n", "difficulty: intermediate\n", "tags: [python, statistics, scipy, data-analysis, surveys]\n", "categories: [Notebooks, Tutorials]\n", "toc: true\n", "comments: true\n", "---\n", "\n", "# Statistical Analysis with Python\n", "\n", "Learn to perform statistical analysis using Python's powerful libraries. This tutorial covers descriptive statistics, hypothesis testing, correlation analysis, and more using real survey response data.\n", "\n", "**What you'll learn:**\n", "- Descriptive statistics (mean, median, mode, variance)\n", "- Correlation analysis\n", "- Hypothesis testing (t-tests, chi-square)\n", "- Normal distribution and normality testing\n", "- Confidence intervals" ] }, { "cell_type": "markdown", "id": "4aa8976a", "metadata": {}, "source": [ "## Setup and Imports" ] }, { "cell_type": "code", "execution_count": 12, "id": "25a1e67b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "โ Libraries imported successfully!\n", "Pandas: 3.0.0\n", "NumPy: 2.4.2\n", "SciPy: 1.17.0\n" ] } ], "source": [ "# Import statistical and data libraries\n", "import pandas as pd\n", "import numpy as np\n", "import scipy\n", "from scipy import stats\n", "from scipy.stats import ttest_ind, chi2_contingency, pearsonr, spearmanr\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "print(\"โ Libraries imported successfully!\")\n", "print(f\"Pandas: {pd.__version__}\")\n", "print(f\"NumPy: {np.__version__}\")\n", "print(f\"SciPy: {scipy.__version__}\")" ] }, { "cell_type": "markdown", "id": "63c12e25", "metadata": {}, "source": [ "## Load Survey Data" ] }, { "cell_type": "code", "execution_count": 3, "id": "5bd6d2fb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "๐ Survey Data Preview:\n", "Shape: 75 respondents ร 13 questions\n", "\n" ] }, { "data": { "text/html": [ "
| \n", " | respondent_id | \n", "age | \n", "gender | \n", "education | \n", "employment | \n", "income_bracket | \n", "product_satisfaction | \n", "service_rating | \n", "would_recommend | \n", "purchase_frequency | \n", "category_preference | \n", "feedback_length | \n", "response_date | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1 | \n", "28 | \n", "Female | \n", "Bachelor's | \n", "Full-time | \n", "50000-75000 | \n", "4 | \n", "5 | \n", "Yes | \n", "Monthly | \n", "Electronics | \n", "142 | \n", "2025-01-15 | \n", "
| 1 | \n", "2 | \n", "35 | \n", "Male | \n", "Master's | \n", "Full-time | \n", "75000-100000 | \n", "5 | \n", "4 | \n", "Yes | \n", "Weekly | \n", "Electronics | \n", "89 | \n", "2025-01-16 | \n", "
| 2 | \n", "3 | \n", "42 | \n", "Female | \n", "Bachelor's | \n", "Part-time | \n", "25000-50000 | \n", "3 | \n", "3 | \n", "Maybe | \n", "Quarterly | \n", "Furniture | \n", "156 | \n", "2025-01-17 | \n", "
| 3 | \n", "4 | \n", "23 | \n", "Male | \n", "High School | \n", "Student | \n", "Under 25000 | \n", "4 | \n", "4 | \n", "Yes | \n", "Monthly | \n", "Electronics | \n", "45 | \n", "2025-01-18 | \n", "
| 4 | \n", "5 | \n", "51 | \n", "Female | \n", "Doctorate | \n", "Full-time | \n", "100000+ | \n", "5 | \n", "5 | \n", "Yes | \n", "Weekly | \n", "Electronics | \n", "203 | \n", "2025-01-19 | \n", "
| 5 | \n", "6 | \n", "31 | \n", "Non-binary | \n", "Bachelor's | \n", "Full-time | \n", "50000-75000 | \n", "4 | \n", "4 | \n", "Yes | \n", "Monthly | \n", "Furniture | \n", "78 | \n", "2025-01-20 | \n", "
| 6 | \n", "7 | \n", "45 | \n", "Male | \n", "Master's | \n", "Self-employed | \n", "75000-100000 | \n", "3 | \n", "2 | \n", "No | \n", "Rarely | \n", "Electronics | \n", "312 | \n", "2025-01-21 | \n", "
| 7 | \n", "8 | \n", "27 | \n", "Female | \n", "Bachelor's | \n", "Full-time | \n", "50000-75000 | \n", "5 | \n", "5 | \n", "Yes | \n", "Monthly | \n", "Electronics | \n", "67 | \n", "2025-01-22 | \n", "
| 8 | \n", "9 | \n", "38 | \n", "Male | \n", "Bachelor's | \n", "Full-time | \n", "75000-100000 | \n", "4 | \n", "4 | \n", "Yes | \n", "Quarterly | \n", "Furniture | \n", "95 | \n", "2025-01-23 | \n", "
| 9 | \n", "10 | \n", "56 | \n", "Female | \n", "High School | \n", "Retired | \n", "25000-50000 | \n", "4 | \n", "5 | \n", "Yes | \n", "Monthly | \n", "Furniture | \n", "124 | \n", "2025-01-24 | \n", "