{"id":126,"date":"2026-03-02T14:05:19","date_gmt":"2026-03-02T09:05:19","guid":{"rendered":"https:\/\/gigz.pk\/python\/?post_type=lesson&#038;p=126"},"modified":"2026-03-16T18:13:29","modified_gmt":"2026-03-16T13:13:29","slug":"working-with-datasets","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/","title":{"rendered":"\u00a0Working with Datasets"},"content":{"rendered":"\n<p>Working with datasets is one of the most important skills in Data Analytics. A dataset is a collection of structured information, usually stored in files like CSV, Excel, or databases.<\/p>\n\n\n\n<p>In Python, we commonly use the pandas library to handle datasets efficiently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Dataset?<\/h2>\n\n\n\n<p>A dataset is a structured collection of data organized in rows and columns.<\/p>\n\n\n\n<p>Rows represent records<br>Columns represent fields or features<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<p>Name | Age | Salary<br>Ali | 25 | 50000<br>Sara | 28 | 60000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Dataset File Formats<\/h2>\n\n\n\n<p>CSV (Comma Separated Values)<br>Excel (.xlsx)<br>JSON<br>SQL Databases<\/p>\n\n\n\n<p>CSV is the most commonly used format in analytics.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Loading a Dataset in Python<\/h2>\n\n\n\n<p>First, install pandas if not installed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install pandas<\/pre>\n\n\n\n<p>Import pandas and load a CSV file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pddf = pd.read_csv(\"data.csv\")<\/pre>\n\n\n\n<p>For Excel files:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df = pd.read_excel(\"data.xlsx\")<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Viewing Data<\/h2>\n\n\n\n<p>Display first 5 rows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.head()<\/pre>\n\n\n\n<p>Display last 5 rows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.tail()<\/pre>\n\n\n\n<p>Check shape (rows and columns):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.shape<\/pre>\n\n\n\n<p>Check column names:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.columns<\/pre>\n\n\n\n<p>Get summary information:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.info()<\/pre>\n\n\n\n<p>Get statistical summary:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.describe()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Selecting Data<\/h2>\n\n\n\n<p>Select a single column:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df[\"Age\"]<\/pre>\n\n\n\n<p>Select multiple columns:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df[[\"Name\", \"Salary\"]]<\/pre>\n\n\n\n<p>Select rows using condition:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df[df[\"Age\"] &gt; 25]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Handling Missing Data<\/h2>\n\n\n\n<p>Check missing values:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.isnull().sum()<\/pre>\n\n\n\n<p>Remove missing values:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.dropna()<\/pre>\n\n\n\n<p>Fill missing values:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.fillna(0)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Sorting Data<\/h2>\n\n\n\n<p>Sort by a column:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.sort_values(\"Salary\")<\/pre>\n\n\n\n<p>Sort in descending order:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.sort_values(\"Salary\", ascending=False)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Saving the Dataset<\/h2>\n\n\n\n<p>Save as CSV:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.to_csv(\"new_data.csv\", index=False)<\/pre>\n\n\n\n<p>Save as Excel:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.to_excel(\"new_data.xlsx\", index=False)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Working with Datasets is Important<\/h2>\n\n\n\n<p>Data analysis starts with understanding and cleaning data.<br>Proper dataset handling helps you:<\/p>\n\n\n\n<p>Understand data structure<br>Identify errors<br>Clean missing values<br>Filter useful information<br>Prepare data for visualization and modeling<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Key Takeaway<\/h2>\n\n\n\n<p>Working with datasets means loading, exploring, cleaning, filtering, and saving data. Mastering these steps is essential for building a strong foundation in Data Analytics.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/python\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">PYTHON FOR DATA ANALYTICS (PYDA) > Introduction to Data Analysis > Working with Datasets<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773656432961\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":64,"template":"","class_list":["post-126","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u00a0Working with Datasets - One Language. Endless Possibilities<\/title>\n<meta name=\"description\" content=\"Learn how to work with datasets in Python using pandas, including loading CSV\/Excel files, exploring data, cleaning, and filtering.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u00a0Working with Datasets - One Language. Endless Possibilities\" \/>\n<meta property=\"og:description\" content=\"Learn how to work with datasets in Python using pandas, including loading CSV\/Excel files, exploring data, cleaning, and filtering.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/\" \/>\n<meta property=\"og:site_name\" content=\"One Language. Endless Possibilities\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T13:13:29+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/working-with-datasets\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/working-with-datasets\\\/\",\"name\":\"\u00a0Working with Datasets - One Language. Endless Possibilities\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\"},\"datePublished\":\"2026-03-02T09:05:19+00:00\",\"dateModified\":\"2026-03-16T13:13:29+00:00\",\"description\":\"Learn how to work with datasets in Python using pandas, including loading CSV\\\/Excel files, exploring data, cleaning, and filtering.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/working-with-datasets\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/working-with-datasets\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/lesson\\\/working-with-datasets\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PYTHON FOR DATA ANALYTICS (PYDA) > Introduction to Data Analysis > Working with Datasets\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/python\\\/\",\"name\":\"One Language. Endless Possibilities\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u00a0Working with Datasets - One Language. Endless Possibilities","description":"Learn how to work with datasets in Python using pandas, including loading CSV\/Excel files, exploring data, cleaning, and filtering.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/","og_locale":"en_US","og_type":"article","og_title":"\u00a0Working with Datasets - One Language. Endless Possibilities","og_description":"Learn how to work with datasets in Python using pandas, including loading CSV\/Excel files, exploring data, cleaning, and filtering.","og_url":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/","og_site_name":"One Language. Endless Possibilities","article_modified_time":"2026-03-16T13:13:29+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/","url":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/","name":"\u00a0Working with Datasets - One Language. Endless Possibilities","isPartOf":{"@id":"https:\/\/gigz.pk\/python\/#website"},"datePublished":"2026-03-02T09:05:19+00:00","dateModified":"2026-03-16T13:13:29+00:00","description":"Learn how to work with datasets in Python using pandas, including loading CSV\/Excel files, exploring data, cleaning, and filtering.","breadcrumb":{"@id":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/python\/lesson\/working-with-datasets\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/python\/"},{"@type":"ListItem","position":2,"name":"PYTHON FOR DATA ANALYTICS (PYDA) > Introduction to Data Analysis > Working with Datasets"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/python\/#website","url":"https:\/\/gigz.pk\/python\/","name":"One Language. Endless Possibilities","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/python\/wp-json\/wp\/v2\/media?parent=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}