{
  "source_file": "0930",
  "source_platform": "Hashnode",
  "author": "Wesley Kambale",
  "title_listed": "Pandas: The Gateway to Data Exploration and Visualization",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://kambale.dev/pandas-the-gateway-to-data-exploration-and-visualization",
  "publish_date": "2023-05-03",
  "corpus_stage": "",
  "notes": "",
  "id": "33f8be02161c",
  "collected_at": "2026-10-02T14:11:40",
  "title": "Introduction to Data Exploration and Visualization with Pandas",
  "body_markdown": "Pandas: The Gateway to Data Exploration and Visualization\nA beginner guide into the works of Pandas, an open-source data structures and analysis tool for Python\nUpdated\nJuly 18, 2023\n•\n5\nmin read\n•\nView as Markdown\nW\nWesley Kambale\nI'm a Machine Learning Engineer passionate about building production-ready ML systems for the African market.\nWith experience in TensorFlow, Keras, and Python-based workflows, I help teams bridge the gap between machine learning research and real-world deployment—especially on resource-constrained devices.\nI'm also a Google Developer Expert in AI. I regularly speak at tech conferences including PyCon Africa, DevFest Kampala, DevFest Nairobi and more and also write technical articles on AI/ML here.\nPart of series\nMachine Learning\nWhat is Pandas?\nNot sure whether Pandas was named after the dearly beloved panda, but Pandas is a popular open-source Python library for data manipulation and analysis. The name is derived from \"\npan\nel\nda\nta\". It offers various tools for data structures and functions in manipulating numerical data.\nThe library includes a DataFrame object for multivariate data manipulation and a Series object for univariate data manipulation with integrated indexing. There are various methods for data manipulation with the help of vectorization. Data set merging, joining, reshaping, and pivoting. And most importantly, tools for reading and writing data in different file formats.\nSo, let's dive into the workings of Pandas. For the installation of Pandas, check the official documentation\nhere\n.\nImporting Pandas\nIn your Google Colab or Jupyter Notebook, we import pandas and assign it an alias for easy reference and use throughout the notebook. The most common alias is\npd\n.\nimport\npandas\nas\npd\nData Exploration\nData exploration is typically the first step of data analysis used to explore and visualize data to uncover insights from the start or identify areas or patterns to dig into more. Using interactive dashboards and point-and-click data exploration, users can better understand the bigger picture and get insights faster.\nReading Data\nThe beauty of Pandas is that it allows you to work with data that is stored in different file formats. As a data analyst, you need to be flexible and ready to work with all sorts of file formats thrown at you. However, the most common file format is\nCSV\n.\nReading a CSV\ndata = pd.read_csv(\n'csv_file_name.csv'\n)\nNote\ndata\nis a variable that will store the file we are reading\npd\nis the alias for Pandas\nread_csv\nis a Pandas function for reading the\nCSV\nfile\nReading a Spreadsheet\n#To read an entire spreadsheet\ndata = pd.read_excel(\n'spreadsheet_file_name.xlsx'\n)\n#If you wish to read a specific sheet in the spreadsheet\ndata = pd.read_excel(\n'spreadsheet_file_name.xlsx'\n, sheetname =\n'sheet_name'\n)\nReading HTML\nFor us to be able to explore data stored in HTML tables, we need to first ensure that the\nBeautifulSoup\npackage is installed using the following command:\npip install BeautifulSoup4\nThen run the following command to read data from the HTML file while importing\nBeautifulSoup\nfirst.\nfrom\nbs4\nimport\nBeautifulSoup\n\ndata = pd.read_html(\n'url_to_html_file'\n)\nFor this article, we are going to use the \"PCOS\" data set. This is non-personal data for Polycystic ovary syndrome obtained from Kaggle. The data set is a CSV file.\nWe will check out the information about the data set to know how many entries it contains. This helps you know whether the data set has\nnull\nvalues that need to be cleaned up.\ndata.info()\nWhen you notice\nnull\nvalues, the best way is to either drop them or fill them will data. Dropping null values helps you get accurate insights from the data during analysis and visualization.\n#You can use the any() function to check for null values by Columns\npd.isnull(data).any()\n# This will drop all columns that contain null values in the entire data set\ndata.dropna()\n#This will fill the null values with the average of BMI\ndata[\n'BMI'\n].fillna(value = data[\n'BMI'\n].mean())\nAfter fixing the null values, we can now go ahead and take a sneak peek at our data. The\nhead()\nfunction enables us to display the first five (5) entries in the data set while the\ntail()\nfunction displays the last five (5) entries in the data set.\ndata.head()\nExploring the Data\nThe GroupBy function\nLooking at our data, we can group the data by PCOS to see which age is affected most and count the number of those with PCOS for each age.\ngroupbyPcos = data.groupby(\n'Age (yrs)'\n).count()\ngroupbyPcos.columns = [\n'Number of PCOS Cases'\n]\ngroupbyPcos\nThe sum() funtion\nThe data set we are dealing with has data on age, height, BMI, etc. and we can sum up this data\ngroupbyPcos = data.groupby(\n'BMI'\n).sum()\nData Visualization\nData visualization allows users to explore and analyze data quickly and easily. This is good to get visual insights on patterns that you are like to have in your model.\nLine Plot\nA line plot is a basic plot that shows the trend of data over time. In Pandas, you can create a line plot using the\nplot()\nfunction. To visualize a simple line plot of the data we have, we run the following code:\n#Line Plot of Sl. No against BMI\ndata.plot(x=\n\"Sl. No\"\n, y=\n\"BMI\"\n, figsize=(\n12\n,\n4\n))\nBar Plot\nA bar plot is a plot that shows the distribution of data in different categories. In Pandas, you can create a bar plot using the\nplot.bar()\nfunction. To visualize a bar plot of the data, we run the following code:\ndata.plot.bar(x=\n\"Sl. No\"\n, y=\n\"BMI\"\n, figsize=(\n12\n,\n4\n))\nScatter Plot\nA scatter plot is a plot that shows the relationship between two variables. In Pandas, you can create a scatter plot using the\nplot.scatter()\nfunction. To visualize a scatter plot of the data, we run the following code:\ndata.plot.scatter(x=\n\"Sl. No\"\n, y=\n\"BMI\"\n, figsize=(\n12\n,\n4\n))\nBox Plot\nA box plot is a plot that shows the distribution of data using quartiles. In Pandas, you can create a box plot using the\nplot.box()\nfunction. To visualize a box plot of the data, we run the following code:\ndata.plot.box(x=\n\"Sl. No\"\n, y=\n\"BMI\"\n, figsize=(\n12\n,\n4\n))\nConclusion\nIn conclusion, Pandas is a very powerful library used to manipulate data and visualize it for analysis. It offers a wide range of functions to enable a user to play around with their data and make sense of it.\nPS: Access the dataset used\nhere\n. (License: MIT License)\n#\npandas\n#\nmachine-learning\n#\ndata-analysis",
  "metadata": {
    "title": "Introduction to Data Exploration and Visualization with Pandas",
    "description": "A beginner guide into the works of Pandas, an open-source data structures and analysis tool for Python",
    "keywords": null,
    "author": null,
    "og:title": "Introduction to Data Exploration and Visualization with Pandas",
    "og:description": "A beginner guide into the works of Pandas, an open-source data structures and analysis tool for Python",
    "og:url": "https://kambale.dev/pandas-the-gateway-to-data-exploration-and-visualization",
    "og:site_name": "Wesley Kambale",
    "og:image": "https://cdn.hashnode.com/res/hashnode/image/upload/v1689690139732/cd229050-cfef-4f04-b1b1-e973a20e9ef0.png",
    "og:image:width": "1200",
    "og:image:height": "630",
    "og:type": "article",
    "twitter:card": "summary_large_image",
    "twitter:creator": "https://twitter.com/WesKambale",
    "twitter:title": "Introduction to Data Exploration and Visualization with Pandas",
    "twitter:description": "A beginner guide into the works of Pandas, an open-source data structures and analysis tool for Python",
    "twitter:image": "https://cdn.hashnode.com/res/hashnode/image/upload/v1689690139732/cd229050-cfef-4f04-b1b1-e973a20e9ef0.png",
    "article:published_time": "2023-05-03T22:40:40.406Z",
    "article:modified_time": "2023-07-18T16:44:15.476Z",
    "article:author": "https://kambale.dev/@kambale"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/33f8be02161c/code/body-000.txt",
      "chars": 20,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-001.txt",
      "chars": 40,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-002.txt",
      "chars": 216,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-003.txt",
      "chars": 27,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-004.txt",
      "chars": 71,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-005.txt",
      "chars": 12,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-006.txt",
      "chars": 287,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-007.txt",
      "chars": 12,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-008.txt",
      "chars": 107,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-009.txt",
      "chars": 40,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-010.txt",
      "chars": 80,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-011.txt",
      "chars": 51,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-012.txt",
      "chars": 55,
      "language": "text"
    },
    {
      "file": "attachments/33f8be02161c/code/body-013.txt",
      "chars": 51,
      "language": "text"
    }
  ],
  "images": [
    {
      "status": "ok",
      "url": "https://cdn.hashnode.com/res/hashnode/image/upload/v1689690139732/cd229050-cfef-4f04-b1b1-e973a20e9ef0.png",
      "bytes": 70070,
      "reused": true,
      "local_path": "attachments/33f8be02161c/images/000.png",
      "src": "https://cdn.hashnode.com/res/hashnode/image/upload/v1689690139732/cd229050-cfef-4f04-b1b1-e973a20e9ef0.png",
      "alt": "Pandas: The Gateway to Data Exploration and Visualization",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://cdn.hashnode.com/res/hashnode/image/upload/v1676325703715/b304ec59-1e5e-4c06-a21a-b7f5b050b743.png",
      "bytes": 22255,
      "reused": true,
      "local_path": "attachments/33f8be02161c/images/002.png",
      "src": "https://cdn.hashnode.com/res/hashnode/image/upload/v1676325703715/b304ec59-1e5e-4c06-a21a-b7f5b050b743.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://cdn.hashnode.com/res/hashnode/image/upload/v1683152781589/92e4563b-07db-4e3f-861d-cfec362eb745.png",
      "bytes": 67362,
      "reused": true,
      "local_path": "attachments/33f8be02161c/images/003.png",
      "src": "https://cdn.hashnode.com/res/hashnode/image/upload/v1683152781589/92e4563b-07db-4e3f-861d-cfec362eb745.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://cdn.hashnode.com/res/hashnode/image/upload/v1683153062953/d1ee420c-70fe-4872-a6d6-035fa0b0711b.png",
      "bytes": 21819,
      "reused": true,
      "local_path": "attachments/33f8be02161c/images/004.png",
      "src": "https://cdn.hashnode.com/res/hashnode/image/upload/v1683153062953/d1ee420c-70fe-4872-a6d6-035fa0b0711b.png",
      "alt": "",
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://kambale.dev/pandas-the-gateway-to-data-exploration-and-visualization.md",
      "label": "View as Markdown",
      "type": "a"
    },
    {
      "href": "https://hashnode.com/@kambale",
      "label": "W",
      "type": "a"
    },
    {
      "href": "https://twitter.com/WesKambale",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://linkedin.com/in/WesKambale",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://kambale.dev/series/ml-series",
      "label": "Part of series Machine Learning",
      "type": "a"
    },
    {
      "href": "https://pandas.pydata.org/docs/getting_started/install.html",
      "label": "here",
      "type": "a"
    },
    {
      "href": "https://drive.google.com/file/d/1_1Jy-VGw3rvYlw4BIaLPzbs-p17aHKKc/view?usp=sharing",
      "label": "here",
      "type": "a"
    },
    {
      "href": "https://kambale.dev/tag/pandas",
      "label": "# pandas",
      "type": "a"
    },
    {
      "href": "https://kambale.dev/tag/machine-learning",
      "label": "# machine-learning",
      "type": "a"
    },
    {
      "href": "https://kambale.dev/tag/data-analysis",
      "label": "# data-analysis",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:50:52Z",
  "source_url": "https://kambale.dev/pandas-the-gateway-to-data-exploration-and-visualization",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 6383,
  "expected_body_images": 4,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/33f8be02161c/pages/source.html",
  "local_html": "attachments/33f8be02161c/pages/article.html",
  "body_base_path": "attachments/33f8be02161c/pages/",
  "body_markdown_path": "attachments/33f8be02161c/pages/article.md"
}