<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Missing Data | Ukant Jadia</title><link>https://ukantjadia.github.io/tag/missing-data/</link><atom:link href="https://ukantjadia.github.io/tag/missing-data/index.xml" rel="self" type="application/rss+xml"/><description>Missing Data</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Sat, 30 Dec 2023 14:19:38 +0530</lastBuildDate><image><url>https://ukantjadia.github.io/media/icon_hu5e29e1df12b63ca0c9252c8db4842f1b_8915_512x512_fill_lanczos_center_3.png</url><title>Missing Data</title><link>https://ukantjadia.github.io/tag/missing-data/</link></image><item><title>Imputation of Missing Data</title><link>https://ukantjadia.github.io/post/imputation-of-missing-data/</link><pubDate>Sat, 30 Dec 2023 14:19:38 +0530</pubDate><guid>https://ukantjadia.github.io/post/imputation-of-missing-data/</guid><description>&lt;h1 id="find-the-missing-data">Find the missing data&lt;/h1>
&lt;p>In order to find the missing data in large dataset we use the functions of pandas library, functions is isnull()&lt;/p>
&lt;ul>
&lt;li>DataFrame_name.isnull()&lt;/li>
&lt;li>it will give the outout as boolean for every element of dataset.&lt;/li>
&lt;li>To get the status of a single comlumn apply the with &lt;code>.any(axis=1)&lt;/code> parameter like &lt;code>df[df.isnull().any(axis-1)]&lt;/code>&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>NOTE: DataFrame_name.isnull() function do not consider an empty string or string with space as missing value. So we have to check and replace the empty string from our dataset if any exist.&lt;/p>
&lt;/blockquote>
&lt;h1 id="process-to-handle-missing-data">Process to Handle Missing Data&lt;/h1>
&lt;p>There are mainly two process to handle the missing data in our observation&lt;/p>
&lt;ol>
&lt;li>drop the missing data by row/column&lt;/li>
&lt;li>Imput the missing values using mean/median/mode&lt;/li>
&lt;/ol>
&lt;ul>
&lt;li>To drop the data row with missing/nan values :&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">df.dropna()
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>We can imput the data in servel ways using the &lt;code>df.fillna()&lt;/code> on the dataset.&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="n">df&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;col_name&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">fillna&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">inplave&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="kc">True&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1"># It will replace nan with 1 in the col_name column&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">df&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;date&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">fillna&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">method&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;ffill&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">inplace&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="kc">True&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1"># It will fill the previous value on the next nan observation &lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>We can also use the mean,mode and median to fill the missing value&lt;/li>
&lt;/ul>
&lt;h1 id="what-if-we-ignore-the-missing-valuedata">What if we ignore the Missing Value/data&lt;/h1>
&lt;ul>
&lt;li>Missing Data can lead to bias and inaccurate result and conclusions.&lt;/li>
&lt;/ul></description></item></channel></rss>