<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Puja Patidar on Medium]]></title>
        <description><![CDATA[Stories by Puja Patidar on Medium]]></description>
        <link>https://medium.com/@patidarpooja12?source=rss-8fecbf4f5743------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gJStFue2-X8C7Xo_</url>
            <title>Stories by Puja Patidar on Medium</title>
            <link>https://medium.com/@patidarpooja12?source=rss-8fecbf4f5743------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 14:28:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patidarpooja12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to handle missing values and Outliers in Pandas]]></title>
            <link>https://medium.com/@patidarpooja12/how-to-handle-missing-values-and-outliers-in-pandas-901ba4b4fe45?source=rss-8fecbf4f5743------2</link>
            <guid isPermaLink="false">https://medium.com/p/901ba4b4fe45</guid>
            <category><![CDATA[missing-values]]></category>
            <category><![CDATA[handeling-outliers]]></category>
            <dc:creator><![CDATA[Puja Patidar]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 18:39:13 GMT</pubDate>
            <atom:updated>2026-07-17T18:39:13.322Z</atom:updated>
            <content:encoded><![CDATA[<p>In real-world data sets, missing values and extreme values are very common. If you are treating them incorrectly, it will lead to wrong business insights, and that will lead to wrong business decisions. So, which imputation method should we apply, and where? will be discussed in this blog. First, we will understand what a missing value means and what outliers are.</p><p><strong>Missing values</strong>: The expected value that should be present in the dataset, but for some reason, it is not available in the dataset. In the raw dataset, it is represented by nan, Nan, blank space, empty cells, or NA.</p><p><strong>Outliers</strong>: An outlier is a rebel data point that simply does not follow the crowd. When you collect a group of data points or information, most of them will naturally cluster close together. An outlier is that one bizarre, extreme value that sits miles away from all the rest, sticking out like a sore thumb</p><p>For example, we are looking at the monthly screen time of 8 teenagers in hours :</p><ul><li><strong>Mayank:</strong> 40 hours</li><li><strong>Maya:</strong> 35 hours</li><li><strong>Suniksha:</strong> 50 hours</li><li><strong>Chetan:</strong> 70 hours</li><li><strong>Jack:</strong> <strong>710</strong> hours</li><li><strong>Shashank: 700</strong> hours</li><li><strong>Pawan</strong>: 70 hours</li><li><strong>Ram</strong>: 65 hours</li></ul><p>In the above data points, Mayank, Maya, Suniksha, Pawan, Ram, and Chetan are all working a relatively normal schedule, ranging between 35 to 70 hours; on the other hand, Jack’s screen time is 710 hours, and Shashank’s screen time is 700 hours. So these 700 and 710 numbers are drastically higher than everyone else’s. In the above data set, these two data points<strong> </strong>can be considered outliers.</p><p>Now that we are comfortable with the definitions of missing values and outliers, let’s talk about various imputation methods based on the type of data:</p><p><strong>Imputation method for the numerical column</strong></p><ol><li>First, you need to plot a histogram of the dataset and use the Interquartile Range (IQR) method to detect the outliers.</li><li>If outliers are present in the dataset or the data distribution is left-skewed or right-skewed, always prefer the <strong>median</strong> value for imputation in numerical columns, because the median is robust to outliers.</li><li>If the data set is normally distributed, which means there is no outlier in the data, then choose the <strong>mean/average</strong> value for data imputation.</li></ol><p><strong>Imputation method for Categorical column</strong></p><ol><li>If you have missing values in a categorical column, for example, in your data set, you have a column of department with values as IT, HR, Sales, etc., we generally prefer the <strong>mode</strong> for imputation</li></ol><p><strong>Now, let’s understand how to handle missing values by using a sample dataset</strong></p><ol><li>Check the dataset size and a few records to understand the data using pandas, as shown in the image below.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*TbYiahGMSzCQuqdu5avvdQ.png" /></figure><p>2. Check data type and nonnull counts as shown in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*bOxysCk4KRCr1O6CwuFuuA.png" /></figure><p>3. View statistical summary of the dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*jO3vuuA9kNUfpdlYTbepvg.png" /></figure><p>4. Check the missing value and the percentage of missing values in the dataset using .isnull().sum() or .isnull().mean()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*KJK_0CZXQSmfGTiSSPA-pw.png" /></figure><p>5. Plot histograms of the dataset as shown here in the images below. Here, histograms are plotted only for columns that contain missing values. We can plot all the columns that are present in the dataset to get an overview of the data distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*eOTBBJy07SWIxBG4Vw266Q.png" /></figure><p>6. Handling missing values with median, mean, and mode.</p><p>First, create a copy so that the original dataframe remains unchanged. and refer to the image below for how we impute in the missing columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Qg72dpSQk2BNimn8ZjMNiQ.png" /></figure><p>7. After imputation, verify that missing values have been handled</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*seeUY-Onos0xDjc9xhr9rA.png" /></figure><p>How to detect and handle outliers</p><p>Detect outliers using the IQR method as shown in the image below by using the Interquartile Range (IQR) method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*bFnuw8jaJo3Z-sqiRyIAXw.png" /></figure><p>2. Handle outliers using the winsorization method :</p><p>Winsorization is an outlier-handling technique that replaces extreme values with selected lower and upper boundary values instead of removing them. It reduces the impact of outliers while keeping all observations in the dataset. Refer to the image below for the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*tBGn9aypQqebKriewEi-Ew.png" /></figure><p>Thank you for reading my blog…!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=901ba4b4fe45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let's read, merge, and inspect the dataset in pandas]]></title>
            <link>https://medium.com/@patidarpooja12/lets-read-merge-and-inspect-the-dataset-in-pandas-a58a1385d049?source=rss-8fecbf4f5743------2</link>
            <guid isPermaLink="false">https://medium.com/p/a58a1385d049</guid>
            <category><![CDATA[data-cleaning]]></category>
            <dc:creator><![CDATA[Puja Patidar]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 18:37:17 GMT</pubDate>
            <atom:updated>2026-07-17T18:37:17.606Z</atom:updated>
            <content:encoded><![CDATA[<p>Why is data cleaning the most important step before any analysis or building any machine learning model?</p><p>Let&#39;s try to understand like this, suppose you have data, and without cleaning the data, you have built a fancy model on it, and you are expecting 99% accurate result from this model. The model works based on what you feed it; if you feed garbage data in, you will get garbage output. We can’t expect polished or accurate result from messy data, so we have to clean the data first to get more accurate results.</p><p>Basic steps that we should perform before starting any analysis or building an ML model.</p><ol><li>Import all required libraries as shown in the image below</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*M9KYAjhqo1Ua6lELqycLyQ.png" /></figure><p>If a library donot exist in your local system, first install it using pip install or conda install or direct installation dependent on IDE used.</p><p>2. Read the file first using <strong>pd.read_csv()</strong> method for CSV file, <strong>pd.read_excel()</strong> method for an Excel file. Here, I have train, test, and store data set files in CSV format that I&#39;m reading, as shown in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*Avp_jp_RxObjXh3ZOTeaaQ.png" /></figure><p>3. Check the <strong>shape</strong> of the data set, here it shows (421570 rows, 5 columns) in the train file, then we can see the data inside the file, how does it look like? To access only the first five rows, we use the <strong>head</strong> method as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*uRGhjYf0tGajENHPRCwBKQ.png" /></figure><p>4. The same process will be done for the store and feature file to get the basic understanding of the data stored in the store and features CSV file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cfg4MfWotyexF_6GMlYNXg.png" /></figure><p>5. How to merge different files in Pandas/Python? As we have 3 different files here: train, store, and features. Here, we are using <strong>left join and merge methods </strong>to merge all the files together, and as a result, we have a single merged data set (df), as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*eXsqSp3cChrvY9W1jlgKXQ.png" /></figure><p>6. As we merged different data files, have a look at the final data to check how the rows and columns look like. In the image below we have <strong>df</strong> as the final data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRurS5fF1Kw7qY1hNrhV8w.png" /></figure><p>We have (421570 rows, 17 columns) in meregd data set.</p><p>7. Next step: Standardise the column name to eliminate case-sensitive issues and improve code readability, see the code and updated column name in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*6-gd7gbVhw9qmn_26TrUnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*avUNISS5h8xHz_-qNYKi-w.png" /></figure><p>8. Now let’s check the health of the dataset by using<strong> </strong>the<strong> info()</strong> method, as shown in the image below, this method shows the total rows, columns, count of non-null records, data type of each column, and memory usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*HGxzo63QO7T1iu9lCqblyA.png" /></figure><p>9. As a<strong> “date”</strong> column is an object type, it is essential to change its data type to a datetime format to enable mathematical operations and unlock time-based analysis. To do that, we use the <strong>to_datetime</strong> method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*J0dj3LWtF_B2gGiUgynY6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xZ7bhSWz0POzW1hElCKyg.png" /></figure><p>10. Before analysing or cleaning a dataset, we need to understand the quality and distribution of the data. Use the <strong>describe </strong>method<strong> </strong>to generate a quick basic statistic profile of a dataset, such as count of records, mean, standard deviation, min, max, etc., as shown in the image below. We used (.T) to transpose the output data for readability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L73vnfDxeGIQFaREJYGXSQ.png" /></figure><h4>Inspecting missing values:</h4><ol><li>Check for the missing values in the dataset, <strong>isnull().sum() </strong>shows the<strong> absolute count</strong> of missing values per column, and also the percentage of missing values for each column by using <strong>isnull().mean(),</strong> which provides the proportion of missing data relative to the total number of rows, then sorts the values in descending order to see the first highest percentage of missing values on top, as shown in the image below</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*mZcBS-bCI0sFVqdXPX_rlw.png" /></figure><p>2. The next step is to handle missing values. The null values are present only in the Markdown columns, which represent promotional discounts. We impute these missing values with zero, assuming that a null Markdown value indicates that no promotion was offered during that period. From the image below, we can see the code and also verify that after imputation, no null values are available in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*UcMRrEoP-euQPHoxHsS8bg.png" /></figure><p>For more details how to treat missing values and outliers read this blog “How to handle missing values and Outliers in Pandas”</p><p>Thank you for reading my first blog…….!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a58a1385d049" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>