{"id":6943,"date":"2025-01-30T06:32:34","date_gmt":"2025-01-30T06:32:34","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=6943"},"modified":"2025-01-30T06:32:38","modified_gmt":"2025-01-30T06:32:38","slug":"how-to-select-rows-from-dataframe-based-on-column-values","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/","title":{"rendered":"How to Select Rows from Dataframe Based on Column Values"},"content":{"rendered":"\n<p>Python developers commonly use Pandas dataframe to store data in tabular manner as columns and rows. It allows you to easily organize data for analysis and manipulation. It also allows you to easily extract specific data as per your requirement. Often software developers want to be able to select specific rows from dataframe just as we do it in SQL databases. In this article, we will learn how to select rows from dataframe based on column values.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><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><\/span><\/a><\/span><\/div>\n<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:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#How_to_Select_Rows_from_Dataframe_Based_on_Column_Values\" >How to Select Rows from Dataframe Based on Column Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#1_Based_on_Single_Value\" >1. Based on Single Value<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#2_Based_on_Multiple_Values\" >2. Based on Multiple Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#3_Using_Single_Condition\" >3. Using Single Condition<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#4_Using_Multiple_Conditions\" >4. Using Multiple Conditions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Select_Rows_from_Dataframe_Based_on_Column_Values\"><\/span>How to Select Rows from Dataframe Based on Column Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Generally, if your data is stored in a relational database platform such as MySQL or PostgreSQL, then you can easily extract specific rows from a table using SQL query as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT *<br>FROM table<br>WHERE column_name = value<\/pre>\n\n\n\n<p>Often Python developers want to replicate this functionality within their Python application or website. Let us say you have a Pandas dataframe.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pd<br><br>data = {<br>  \"id\": [1, 2, 3],<br>  \"name\":['John','Jim','Jane'],<br>  \"marks\": [50, 40, 45]<br>}<br><br>#load data into a DataFrame object:<br>df = pd.DataFrame(data)<br><br>print(df) <\/pre>\n\n\n\n<p>Here is the output you will see.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Output<br><br>   id  name  marks<br>0   1  John     50<br>1   2   Jim     40<br>2   3  Jane     45<\/pre>\n\n\n\n<p>Let us look at some of the common ways to select rows from the above dataframe. For our purpose, we will use <a href=\"https:\/\/pandas.pydata.org\/docs\/reference\/api\/pandas.DataFrame.loc.html\">loc()<\/a> built-in function available to each dataframe. It allows you to access rows and columns of a dataframe using one or more conditions. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dataframe.loc()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Based_on_Single_Value\"><\/span>1. Based on Single Value<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One of the most common requirements for Python programmers is to select one or more rows in a dataframe, based on the single value of a column. You can do this using the &#8216;==&#8217; operator in the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.loc[df['column_name'] == value]<\/pre>\n\n\n\n<p>Here is the code to select rows where marks column has value 50.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.loc[df['marks'] == 50]<\/pre>\n\n\n\n<p>When you print the result of above statement, here is the output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks'] == 50]) <br><br>## Output<br>   id  name  marks<br>0   1  John     50<\/pre>\n\n\n\n<p>Similarly, if you want to select rows where the value IS NOT 50, then use &#8216;!=&#8217; operator for this purpose.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks']!=50]) <br><br>## Output<br><br>   id  name  marks<br>1   2   Jim     40<br>2   3  Jane     45<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Based_on_Multiple_Values\"><\/span>2. Based on Multiple Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Similarly, you may need to select rows that match one or more values from a set of values. You can do this using isin() function. Here is the syntax to select rows based on multiple values of a column.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">df.loc[df['column_name'].isin(values)]<\/pre>\n\n\n\n<p>Here is an example to select rows where marks is in (40, 50). Please note, you need to pass an iterable like a tuple or list containing the values, in isin() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks'].isin((40,50))]) <br><br>## Output<br><br>   id  name  marks<br>0   1  John     50<br>1   2   Jim     40<\/pre>\n\n\n\n<p>Here is an example using list of values [40, 50].<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks'].isin([40,50])]) <\/pre>\n\n\n\n<p>On the other hand, if you need to select rows where a column does not have a set of values, then you need to add &#8216;~&#8217; operator before the dataframe loc() function as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[<strong>~<\/strong>df['marks'].isin([40,50])]) <\/pre>\n\n\n\n<p>Here is the output.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">## Output<br><br>   id  name  marks<br>2   3  Jane     45<\/pre>\n\n\n\n<p>Please note, if you only supply the values in a comma separated manner, without enclosing them in an iterable, you will get an error. Here is an example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks'].isin(40,50)])<\/pre>\n\n\n\n<p>Here is the error message.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Traceback (most recent call last):<br>  File \"&lt;main.py>\", line 12, in &lt;module><br>TypeError: Series.isin() takes 2 positional arguments but 3 were given<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_Single_Condition\"><\/span>3. Using Single Condition<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Instead of using = or != operator, you can also use other conditional operators like &lt;=, >=, &lt;, > to select rows according to various conditions. Here is an example to select rows where marks>=45.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[df['marks']>=45]) <br><br>## Output<br><br>   id  name  marks<br>0   1  John     50<br>2   3  Jane     45<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_Multiple_Conditions\"><\/span>4. Using Multiple Conditions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes you may need to filter rows based on more than one condition. In such cases, you can combine the above mentioned single conditions using &#8216;&amp;&#8217; operator. Here is an example to select rows where marks>=40 and marks&lt;=45.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.loc[(df['marks'] >= 40) &amp; (df['marks'] &lt;= 45)])<\/pre>\n\n\n\n<p>Here is the output you will see.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">## Output<br><br>   id  name  marks<br>1   2   Jim     40<br>2   3  Jane     45<\/pre>\n\n\n\n<p>In the above example, please note the placement of round brackets &#8216;(&#8230;)&#8217; around &#8220;df[&#8216;marks&#8217;] >= 40&#8221; and &#8220;df[&#8216;marks&#8217;] &lt;= 45&#8221;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several different ways to select one or more rows from pandas dataframe in Python. You can use any of the solutions described above, as per your requirement.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-concatenate-two-lists-in-python\/\">How to Concatenate Two Lists in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-list-all-files-in-directory\/\">How to List All Files in Directory<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-clone-list-in-python\/\">How to Clone List in Python<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often Python developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.<\/p>\n","protected":false},"author":1,"featured_media":6965,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[383],"class_list":["post-6943","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-select-rows"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Select Rows from Dataframe Based on Column Values - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Select Rows from Dataframe Based on Column Values - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-30T06:32:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-30T06:32:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"256\" \/>\n\t<meta property=\"og:image:height\" content=\"171\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Select Rows from Dataframe Based on Column Values\",\"datePublished\":\"2025-01-30T06:32:34+00:00\",\"dateModified\":\"2025-01-30T06:32:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\"},\"wordCount\":610,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1\",\"keywords\":[\"select rows\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\",\"name\":\"How to Select Rows from Dataframe Based on Column Values - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1\",\"datePublished\":\"2025-01-30T06:32:34+00:00\",\"dateModified\":\"2025-01-30T06:32:38+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1\",\"width\":256,\"height\":171,\"caption\":\"select rows by column values\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Select Rows from Dataframe Based on Column Values\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Select Rows from Dataframe Based on Column Values - Ubiq BI","description":"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.","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:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/","og_locale":"en_US","og_type":"article","og_title":"How to Select Rows from Dataframe Based on Column Values - Ubiq BI","og_description":"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-01-30T06:32:34+00:00","article_modified_time":"2025-01-30T06:32:38+00:00","og_image":[{"width":256,"height":171,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Select Rows from Dataframe Based on Column Values","datePublished":"2025-01-30T06:32:34+00:00","dateModified":"2025-01-30T06:32:38+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/"},"wordCount":610,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1","keywords":["select rows"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/","name":"How to Select Rows from Dataframe Based on Column Values - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1","datePublished":"2025-01-30T06:32:34+00:00","dateModified":"2025-01-30T06:32:38+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Often developers need to extract specific rows from Pandas dataframe. Here is how to select rows from dataframe based on column values.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1","width":256,"height":171,"caption":"select rows by column values"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-select-rows-from-dataframe-based-on-column-values\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Select Rows from Dataframe Based on Column Values"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/01\/select-rows-column-values.jpg?fit=256%2C171&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-1NZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/6943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=6943"}],"version-history":[{"count":29,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/6943\/revisions"}],"predecessor-version":[{"id":6973,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/6943\/revisions\/6973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/6965"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=6943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=6943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=6943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}