{"id":25525486,"date":"2022-05-27T02:17:25","date_gmt":"2022-05-26T20:47:25","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25525486"},"modified":"2023-11-23T10:23:06","modified_gmt":"2023-11-23T04:53:06","slug":"python-fundamentals-for-data-science-an-overview","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/","title":{"rendered":"Python Fundamentals for Data Science- An Overview"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69d2fbe76c9c8\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69d2fbe76c9c8\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#1_Data_Types_and_Structures\" >1. Data Types and Structures<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#2_Compound_data_structures_lists_tuples_and_dictionaries\" >2. Compound data structures (lists, tuples, and dictionaries)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#3_Conditionals_Loops_and_Functions\" >3. Conditionals, Loops, and Functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#Introduction_To_Machine_Learning_using_Python\" >Introduction To Machine Learning using Python<\/a><\/li><\/ul><\/nav><\/div>\n<p>Beginners in the field of data science who are not familiar with programming often have a hard time figuring out where they should start.<\/p>\n<p>With hundreds of questions about how to get started with\u00a0Python for Data Science on various forums, this post is an answer to settle all those questions.<\/p>\n<p>So, here are the fundamentals to help you with <a href=\"https:\/\/entri.app\/course\/python-programming-course\/\">programming in Python<\/a>.<\/p>\n<p><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25520910 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png\" alt=\"Python and Machine Learning Square\" width=\"345\" height=\"345\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square.png 345w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-300x300.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-150x150.png 150w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-24x24.png 24w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-48x48.png 48w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-96x96.png 96w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Square-75x75.png 75w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/a><\/p>\n<p>A basic Python curriculum can be broken down into 4 essential topics that include:<\/p>\n<ol>\n<li>Data types (int, float, strings)<\/li>\n<li>Compound data structures (lists, tuples, and dictionaries)<\/li>\n<li>Conditionals, loops, and functions<\/li>\n<li>Object-oriented programming and using external libraries<\/li>\n<\/ol>\n<p>Let&#8217;s go over each one and see what are the fundamentals you should learn.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h2 id=\"1-data-types-and-structures\"><span class=\"ez-toc-section\" id=\"1_Data_Types_and_Structures\"><\/span><strong>1. Data Types and Structures<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The very first step is to understand how Python interprets data.<\/p>\n<p>Starting with widely used data types, you should be familiar with integers (int), floats (float), strings (str), and booleans (bool). Here&#8217;s what you should practice.<\/p>\n<h3 id=\"type-typecasting-and-i-o-functions-\"><strong>Type, typecasting, and I\/O functions:<\/strong><\/h3>\n<ul>\n<li>Learning the type of data using the\u00a0<code>type()<\/code>\u00a0method.<\/li>\n<\/ul>\n<pre class=\" language-py\"><code class=\" language-py\">type('Harshit')\r\n\r\n# output: str\r\n<\/code><\/pre>\n<ul>\n<li>Storing values into variables and input-output functions (<code>a = 5.67<\/code>)<\/li>\n<li>Typecasting \u2014 converting a particular type of variable\/data into another type if possible. For example, converting a string of integers into an integer:<\/li>\n<\/ul>\n<pre class=\" language-py\"><code class=\" language-py\">astring = \"55\"\r\nprint(type(astring))\r\n\r\n# output: &lt;class 'str'&gt;\r\n<\/code><\/pre>\n<pre class=\" language-py\"><code class=\" language-py\">astring = int(astring)\r\nprint(type(astring))\r\n\r\n# output: &lt;class 'int64'&gt;\r\n<\/code><\/pre>\n<p>Once you are familiar with the basic data types and their usage, you should learn about\u00a0arithmetic operators and expression evaluations\u00a0(DMAS)\u00a0and how you can store the result in a variable for further use.<\/p>\n<pre class=\" language-py\"><code class=\" language-py\">answer = 43 + 56 \/ 14 - 9 * 2\r\nprint(answer)\r\n\r\n# output: 29.0\r\n<\/code><\/pre>\n<h3 id=\"strings-\"><strong>Strings:<\/strong><\/h3>\n<p>Knowing how to deal with textual data and their operators comes in handy when dealing with the string data type. Practice these concepts:<\/p>\n<ul>\n<li>Concatenating strings using\u00a0<code>+<\/code><\/li>\n<li>Splitting and joining the string using the\u00a0<code>split()<\/code>\u00a0and\u00a0<code>join()<\/code>method<\/li>\n<li>Changing the case of the string using\u00a0<code>lower()<\/code>\u00a0and\u00a0<code>upper()<\/code>\u00a0methods<\/li>\n<li>Working with substrings of a string<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td style=\"text-align: center;\" colspan=\"3\">\n<h5><strong>Are you aspiring for a booming career in IT? If YES, then dive in<\/strong><\/h5>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<h5><a href=\"https:\/\/entri.app\/course\/full-stack-developer-course\/\"><strong>Full Stack Developer Course<\/strong><\/a><\/h5>\n<\/td>\n<td>\n<h5><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\"><strong>Python Programming Course<\/strong><\/a><\/h5>\n<\/td>\n<td>\n<h5><a href=\"https:\/\/entri.app\/course\/data-science-and-machine-learning-course\/\"><strong>Data Science and Machine Learning Course<\/strong><\/a><\/h5>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"2-compound-data-structures-lists-tuples-and-dictionaries-\"><span class=\"ez-toc-section\" id=\"2_Compound_data_structures_lists_tuples_and_dictionaries\"><\/span><strong>2. Compound data structures (lists, tuples, and dictionaries)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 id=\"lists-and-tuples-compound-data-types-\"><strong>Lists and tuples (compound data types):<\/strong><\/h3>\n<p>One of the most important and commonly used data structures in Python are lists. A list is a collection of elements, and the collection can be of the same or varied data types.<\/p>\n<p>Understanding lists will eventually pave the way for computing algebraic equations and statistical models on your array of data.<\/p>\n<p>Here are the concepts you should be familiar with:<\/p>\n<ul>\n<li>How multiple data types can be stored in a Python list.<\/li>\n<li>Indexing and slicing\u00a0to access a specific element or sub-list of the list.<\/li>\n<li>Helper methods for\u00a0sorting, reversing, deleting elements, copying, and appending.<\/li>\n<li>Nested lists \u2014 lists containing lists. For example,\u00a0<code>[1,2,3, [10,11]]<\/code>.<\/li>\n<li>Addition in a list.<\/li>\n<\/ul>\n<pre class=\" language-py\"><code class=\" language-py\">alist + alist\r\n\r\n# output: ['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]<\/code><\/pre>\n<p>Multiplying the list with a scalar:<\/p>\n<pre class=\" language-py\"><code class=\" language-py\">alist * 2\r\n\r\n# output: ['harshit', 2, 5.5, 10, [1, 2, 3], 'harshit', 2, 5.5, 10, [1, 2, 3]]<\/code><\/pre>\n<figure class=\"kg-card kg-image-card kg-width-wide\"><img loading=\"lazy\" decoding=\"async\" class=\"kg-image\" src=\"https:\/\/www.freecodecamp.org\/news\/content\/images\/2020\/07\/5.png\" alt=\"5\" width=\"600\" height=\"400\" \/><\/figure>\n<p>Tuples\u00a0are an immutable ordered sequence of items. They are similar to lists, but the\u00a0key difference is that\u00a0tuples\u00a0are immutable whereas lists are mutable.<\/p>\n<p>Concepts to focus on:<\/p>\n<ul>\n<li>Indexing and slicing (similar to lists).<\/li>\n<li>Nested tuples.<\/li>\n<li>Adding tuples and helper methods like\u00a0<code>count()<\/code>\u00a0and\u00a0<code>index()<\/code>.<\/li>\n<\/ul>\n<h3 id=\"dictionaries\"><strong>Dictionaries<\/strong><\/h3>\n<p>These are another type of collection in Python. While lists are integer indexed, dictionaries are more like addresses. Dictionaries have key-value pairs, and keys are analogous to indexes in lists.<\/p>\n<p>To access an element, you need to pass the key in squared brackets.<\/p>\n<figure class=\"kg-card kg-image-card\"><img loading=\"lazy\" decoding=\"async\" class=\"kg-image\" src=\"https:\/\/www.freecodecamp.org\/news\/content\/images\/2020\/07\/7.png\" alt=\"7\" width=\"600\" height=\"400\" \/><\/figure>\n<p>Concepts to focus on:<\/p>\n<ul>\n<li>Iterating through a dictionary (also covered in loops).<\/li>\n<li>Using helper methods like\u00a0<code>get()<\/code>,\u00a0<code>pop()<\/code>,\u00a0<code>items()<\/code>,\u00a0<code>keys()<\/code>,\u00a0<code>update()<\/code>, and so on.<\/li>\n<\/ul>\n<h2 id=\"3-conditionals-loops-and-functions\"><span class=\"ez-toc-section\" id=\"3_Conditionals_Loops_and_Functions\"><\/span><strong>3. Conditionals, Loops, and Functions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 id=\"conditions-and-branching\"><strong>Conditions and Branching<\/strong><\/h3>\n<p>Python uses these boolean variables to assess conditions. Whenever there is a comparison or evaluation, boolean values are the resulting solution.<\/p>\n<pre class=\" language-py\"><code class=\" language-py\">x = True\r\n\r\nptint(type(x))\r\n\r\n# output: &lt;class bool&gt;<\/code><\/pre>\n<pre class=\" language-py\"><code class=\" language-py\">print(1 == 2)\r\n\r\n# output: False<\/code><\/pre>\n<p>The comparison in the image needs to be observed carefully as people confuse the assignment operator (<code>=<\/code>) with the comparison operator (<code>==<\/code>).<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h3 id=\"boolean-operators-or-and-not-\"><strong>Boolean operators (or, and, not)<\/strong><\/h3>\n<p>These are used to evaluate complex assertions together.<\/p>\n<ul>\n<li><code>or<\/code>\u00a0\u2014 One of the many comparisons should be true for the entire condition to be true.<\/li>\n<li><code>and<\/code>\u00a0\u2014 All of the comparisons should be true for the entire condition to be true.<\/li>\n<li><code>not<\/code>\u00a0\u2014 Checks for the opposite of the comparison specified.<\/li>\n<\/ul>\n<p>Concepts to learn :<\/p>\n<ul>\n<li><code>if<\/code>,\u00a0<code>else<\/code>, and\u00a0<code>elif<\/code>\u00a0statements to construct your condition.<\/li>\n<li>Making complex comparisons in one condition.<\/li>\n<li>Keeping indentation in mind while writing nested\u00a0<code>if<\/code>\u00a0\/\u00a0<code>else<\/code>\u00a0statements.<\/li>\n<li>Using boolean,\u00a0<code>in<\/code>,\u00a0<code>is<\/code>, and\u00a0<code>not<\/code>\u00a0operators.<\/li>\n<\/ul>\n<h3 id=\"loops\"><strong>Loops<\/strong><\/h3>\n<p>Often you&#8217;ll need to do a repetitive task, and loops will be your best friend to eliminate the overhead of code redundancy. You\u2019ll often need to iterate through each element of a list or dictionary, and loops come in handy for that.\u00a0<code>while<\/code>\u00a0and\u00a0<code>for<\/code>\u00a0are two types of loops.<\/p>\n<h3 style=\"text-align: center;\"><a class=\"btn btn-default\" href=\"https:\/\/entri.app\/course\/python-programming-course\/\">get into most in demand career by learning python programming !<\/a><\/h3>\n<h3 id=\"list-comprehension\"><strong>List Comprehension<\/strong><\/h3>\n<p>A sophisticated and succinct way of creating a list using and iterable followed by a\u00a0<code>for<\/code>\u00a0clause.<\/p>\n<p>For example, you can create a list of 9 cubes as shown in the example above using list comprehension.<\/p>\n<pre class=\" language-py\"><code class=\" language-py\"># list comprehension\r\ncubes = [n** 3 for n in range(1,10)]\r\nprint(cubes)\r\n\r\n# output: [1, 8, 27, 64, 125, 216, 343, 512, 729]<\/code><\/pre>\n<h3 id=\"functions\"><strong>Functions<\/strong><\/h3>\n<p>While working on a big project, maintaining code becomes a real chore. If your code performs similar tasks many times, a convenient way to manage your code is by using functions.<\/p>\n<p>A function is a block of code that performs some operations on input data and gives you the desired output.<\/p>\n<p>Using functions makes the code more readable, reduces redundancy, makes the code reusable, and saves time.<\/p>\n<p>Python uses indentation to create blocks of code. This is an example of a function:<\/p>\n<pre class=\" language-py\"><code class=\" language-py\">def add_two_numbers(a, b):\r\n    sum = a + b\r\n    return sum\r\n<\/code><\/pre>\n<p>We define a function using the\u00a0<code>def<\/code>\u00a0keyword followed by the name of the function and arguments (input) within the parentheses, followed by a colon.<\/p>\n<p>The body of the function is the indented code block, and the output is returned with the\u00a0<code>return<\/code>\u00a0keyword.<\/p>\n<p>You call a function by specifying the name and passing the arguments within the parentheses as per the definition.<strong>4. Object-Oriented programming and using external libraries<\/strong><\/p>\n<p>We have been using the helper methods for lists, dictionaries, and other data types, but where are these coming from?<\/p>\n<p>When we say list or dict, we are actually interacting with a list class object or a dict class object. Printing the type of a\u00a0<em>dictionary object\u00a0<\/em>will show you that it is a class dict object.<\/p>\n<figure class=\"kg-card kg-image-card\"><img loading=\"lazy\" decoding=\"async\" class=\"kg-image\" src=\"https:\/\/www.freecodecamp.org\/news\/content\/images\/2020\/07\/15.png\" alt=\"15\" width=\"600\" height=\"400\" \/><\/figure>\n<p>These are all pre-defined classes in the Python language, and they make our tasks very easy and convenient.<\/p>\n<p>Objects are instance of a class and are defined as an encapsulation of variables (data) and functions into a single entity. They have access to the variables (attributes) and methods (functions) from classes.<\/p>\n<h3 id=\"using-external-libraries-modules\"><strong>Using External Libraries\/Modules<\/strong><\/h3>\n<p>One of the main reasons to use Python for data science is the amazing community that develops high-quality packages for different domains and problems. Using external libraries and modules is an integral part of working on projects in Python.<\/p>\n<p>These libraries and modules have defined classes, attributes, and methods that we can use to accomplish our tasks. For example, the\u00a0<code>math<\/code>\u00a0library contains many mathematical functions that we can use to carry out our calculations. The libraries are\u00a0<code>.py<\/code>\u00a0files.<\/p>\n<p>You should learn to:<\/p>\n<ul>\n<li>Import libraries in your workspace<\/li>\n<li>Using the\u00a0<code>help<\/code>\u00a0function to learn about a library or function<\/li>\n<li>Importing the required function directly.<\/li>\n<li>How to read the documentation of the well-known packages like pandas, numpy, and sklearn and use them in your projects<\/li>\n<\/ul>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/entri.app\/course\/data-science-and-machine-learning-course\/\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Data Science with Entri! Click Here<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Introduction_To_Machine_Learning_using_Python\"><\/span><strong>Introduction To Machine Learning using Python<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Machine learning is a type of artificial intelligence (AI) that provides computers with the ability to learn without being explicitly programmed. Machine learning focuses on the development of Computer Programs that can change when exposed to new data. Here, we will see basics of Machine Learning, and implementation of a simple machine learning algorithm using python.<\/p>\n<p><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25522670 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"Python and Machine Learning Rectangle\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<div class=\"text\">\n<h4><strong>Setting up the environment<\/strong><\/h4>\n<p>Python community has developed many modules to help programmers implement machine learning. In this article, we will be using numpy, scipy and scikit-learn modules. We can install them using cmd command:<\/p>\n<div id=\"GFG_AD_gfg_mobile_336x280\"><\/div>\n<pre>pip install numpy scipy scikit-learn<\/pre>\n<p>A better option would be downloading miniconda or anaconda packages for python, which come prebundled with these packages. Follow the instructions given\u00a0here\u00a0to use anaconda.<\/p>\n<h4><strong>Machine Learning overview<\/strong><\/h4>\n<p>Machine learning involves a computer to be trained using a given data set, and use this training to predict the properties of a given new data. For example, we can train a computer by feeding it 1000 images of cats and 1000 more images which are not of a cat, and tell each time to the computer whether a picture is cat or not. Then if we show the computer a new image, then from the above training, the computer should be able to tell whether this new image is a cat or not.<br \/>\nThe process of training and prediction involves the use of specialized algorithms. We feed the training data to an algorithm, and the algorithm uses this training data to give predictions on a new test data. One such algorithm is\u00a0K-Nearest-Neighbor\u00a0classification (KNN classification). It takes a test data, and finds k nearest data values to this data from test data set. Then it selects the neighbor of maximum frequency and gives its properties as the prediction result. For example if the training set is:<\/p>\n<figure class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>petal_size<\/th>\n<th>flower_type<\/th>\n<\/tr>\n<tr>\n<th>1<\/th>\n<th>a<\/th>\n<\/tr>\n<tr>\n<th>2<\/th>\n<th>b<\/th>\n<\/tr>\n<tr>\n<th>1<\/th>\n<th>a<\/th>\n<\/tr>\n<tr>\n<th>2<\/th>\n<th>b<\/th>\n<\/tr>\n<tr>\n<th>3<\/th>\n<th>c<\/th>\n<\/tr>\n<tr>\n<th>4<\/th>\n<th>d<\/th>\n<\/tr>\n<tr>\n<th>3<\/th>\n<th>c<\/th>\n<\/tr>\n<tr>\n<th>2<\/th>\n<th>b<\/th>\n<\/tr>\n<tr>\n<th>5<\/th>\n<th>a<\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Now we want to predict flower type for petal of size 2.5 cm. So if we decide no. of neighbors (K)=3, we see that the 3 nearest neighbors of 2.5 are 1, 2 and 3. Their frequencies are 2, 3 and 2 respectively. Therefore the neighbor of maximum frequency is 2 and flower type corresponding to it is b. So for a petal of size 2.5, the prediction will be flower type b.<\/p>\n<\/div>\n<table>\n<tbody>\n<tr>\n<td style=\"text-align: center;\" colspan=\"3\"><strong>Our Other Courses<\/strong><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/entri.app\/course\/mep-course\/\"><strong>MEP Course<\/strong><\/a><\/td>\n<td><a href=\"https:\/\/entri.app\/course\/quantity-surveying-course\/\"><strong>Quantity Surveying Course<\/strong><\/a><\/td>\n<td><a href=\"https:\/\/entri.app\/course\/montessori-teachers-training-course\/\"><strong>Montessori Teachers Training Course<\/strong><\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"https:\/\/entri.app\/course\/performance-marketing-course\/\"><strong>Performance Marketing Course\u00a0<\/strong><\/a><\/td>\n<td><a href=\"https:\/\/entri.app\/course\/practical-accounting-course\/\"><strong>Practical Accounting Course<\/strong><\/a><\/td>\n<td><a href=\"https:\/\/entri.app\/course\/yoga-teachers-training-course\/\"><strong>Yoga Teachers Training Course<\/strong><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Beginners in the field of data science who are not familiar with programming often have a hard time figuring out where they should start. With hundreds of questions about how to get started with\u00a0Python for Data Science on various forums, this post is an answer to settle all those questions. So, here are the fundamentals [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":25525694,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1903,1864],"tags":[],"class_list":["post-25525486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-coding","category-data-science-ml"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Fundamentals for Data Science- An Overview - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Fundamentals for Data Science- An Overview - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Beginners in the field of data science who are not familiar with programming often have a hard time figuring out where they should start. With hundreds of questions about how to get started with\u00a0Python for Data Science on various forums, this post is an answer to settle all those questions. So, here are the fundamentals [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-26T20:47:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-23T04:53:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Feeba Mahin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Feeba Mahin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\"},\"author\":{\"name\":\"Feeba Mahin\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\"},\"headline\":\"Python Fundamentals for Data Science- An Overview\",\"datePublished\":\"2022-05-26T20:47:25+00:00\",\"dateModified\":\"2023-11-23T04:53:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\"},\"wordCount\":1582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png\",\"articleSection\":[\"Articles\",\"Coding\",\"Data Science and Machine Learning\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\",\"url\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\",\"name\":\"Python Fundamentals for Data Science- An Overview - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png\",\"datePublished\":\"2022-05-26T20:47:25+00:00\",\"dateModified\":\"2023-11-23T04:53:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png\",\"width\":820,\"height\":615,\"caption\":\"Python Fundamentals for Data Science,An Overview\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Data Science and Machine Learning\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/data-science-ml\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Python Fundamentals for Data Science- An Overview\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36\",\"name\":\"Feeba Mahin\",\"url\":\"https:\/\/entri.app\/blog\/author\/feeba123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Fundamentals for Data Science- An Overview - Entri Blog","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:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/","og_locale":"en_US","og_type":"article","og_title":"Python Fundamentals for Data Science- An Overview - Entri Blog","og_description":"Beginners in the field of data science who are not familiar with programming often have a hard time figuring out where they should start. With hundreds of questions about how to get started with\u00a0Python for Data Science on various forums, this post is an answer to settle all those questions. So, here are the fundamentals [&hellip;]","og_url":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-05-26T20:47:25+00:00","article_modified_time":"2023-11-23T04:53:06+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png","type":"image\/png"}],"author":"Feeba Mahin","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Feeba Mahin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/"},"author":{"name":"Feeba Mahin","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36"},"headline":"Python Fundamentals for Data Science- An Overview","datePublished":"2022-05-26T20:47:25+00:00","dateModified":"2023-11-23T04:53:06+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/"},"wordCount":1582,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png","articleSection":["Articles","Coding","Data Science and Machine Learning"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/","url":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/","name":"Python Fundamentals for Data Science- An Overview - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png","datePublished":"2022-05-26T20:47:25+00:00","dateModified":"2023-11-23T04:53:06+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Python-Fundamentals-for-Data-ScienceAn-Overview.png","width":820,"height":615,"caption":"Python Fundamentals for Data Science,An Overview"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/python-fundamentals-for-data-science-an-overview\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Data Science and Machine Learning","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/data-science-ml\/"},{"@type":"ListItem","position":4,"name":"Python Fundamentals for Data Science- An Overview"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/f036dab84abae3dcc9390a1110d95d36","name":"Feeba Mahin","url":"https:\/\/entri.app\/blog\/author\/feeba123\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25525486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25525486"}],"version-history":[{"count":10,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25525486\/revisions"}],"predecessor-version":[{"id":25568878,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25525486\/revisions\/25568878"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25525694"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25525486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25525486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25525486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}