{"id":124576,"date":"2022-05-06T19:22:23","date_gmt":"2022-05-06T19:22:23","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=347248"},"modified":"2022-05-06T19:22:23","modified_gmt":"2022-05-06T19:22:23","slug":"how-to-read-specific-columns-from-csv-file-in-python","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/05\/06\/how-to-read-specific-columns-from-csv-file-in-python\/","title":{"rendered":"How to Read Specific Columns from CSV File in Python"},"content":{"rendered":"<div class=\"kk-star-ratings kksr-valign-top kksr-align-left \" data-payload=\"{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;347248&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;count&quot;:&quot;0&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;}\">\n<div class=\"kksr-stars\">\n<div class=\"kksr-stars-inactive\">\n<div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<div class=\"kksr-star\" style=\"padding-right: 5px\">\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n<div class=\"kksr-legend\"> <span class=\"kksr-muted\">Rate this post<\/span> <\/div>\n<\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_21 counter-hierarchy counter-decimal ez-toc-light-blue\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Table of Contents<\/p>\n<p><span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav>\n<ul class=\"ez-toc-list ez-toc-list-level-1\">\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Method_1_Using_Pandas\" title=\"Method 1: Using Pandas\">Method 1: Using Pandas<\/a>\n<ul class=\"ez-toc-list-level-3\">\n<li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#%E2%9E%A4_List-Based_Indexing_of_a_DataFrame\" title=\"\u27a4 List-Based Indexing of a DataFrame\">\u27a4 List-Based Indexing of a DataFrame<\/a><\/li>\n<\/ul>\n<\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Method_2_Integer_Based_Indexing_with_iloc\" title=\"Method 2: Integer Based Indexing with iloc\">Method 2: Integer Based Indexing with iloc<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Method_3_Name-Based_Indexing_with_loc\" title=\"Method 3: Name-Based Indexing with loc()\">Method 3: Name-Based Indexing with loc()<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Method_4_Using_csv_Module\" title=\"Method 4: Using csv Module\">Method 4: Using csv Module<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li>\n<li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.finxter.com\/how-to-read-specific-columns-from-csv-file-in-python\/#Learn_Pandas_the_Fun_Way_by_Solving_Code_Puzzles\" title=\"Learn Pandas the Fun Way by Solving Code Puzzles\">Learn Pandas the Fun Way by Solving Code Puzzles<\/a><\/li>\n<\/ul>\n<\/nav>\n<\/div>\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"337\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2022\/05\/Read-specific-columns-of-a-given-CSV.gif\" alt=\"\" class=\"wp-image-347521\" \/><figcaption>A Quick Glance at The Solutions [Each solution stays for 5-10 secs.]<\/figcaption><\/figure>\n<p><strong>Problem: <\/strong>Given a CSV file, how to read only specific column(s) from the csv file? (Reading a specific column from a csv file will yield all the row values pertaining to that column.)<\/p>\n<p><strong>Example: <\/strong>Consier the following <code>csv<\/code> file (<code>countries.csv<\/code>):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"monokai\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Country,Capital,Population,Area\nGermany,Berlin,\"84,267,549\",\"348,560\"\nFrance,Paris,\"65,534,239\",\"547,557\"\nSpain,Madrid,\"46,787,468\",\"498,800\"\nItaly,Rome,\"60,301,346\",\"294,140\"\nIndia,Delhi,\"1,404,495,187\",\"2,973,190\"\nUSA,Washington,\"334,506,463\",\"9,147,420\"\nChina,Beijing,\"1,449,357,022\",\"9,388,211\"\nPoland,Warsaw,\"37,771,789\",\"306,230\"\nRussia,Moscow,\"146,047,418\",\"16,376,870\"\nEngland,London,\"68,529,747\",\"241,930\"<\/pre>\n<p><strong>Question:<\/strong> How will you read the above csv file and display the following columns <\/p>\n<ol>\n<li><code>Country<\/code> column along with the <code>Capital<\/code> column?<\/li>\n<li>All values in the <code>population<\/code> column?<\/li>\n<\/ol>\n<h2><strong>Method 1: Using <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a><\/strong><\/h2>\n<p>Using the Pandas library is probably the best option if you are dealing with csv files. You can easily read a csv file and store an entire column within a variable. <\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd df = pd.read_csv(\"countries.csv\")\ncountry = df['Country']\n# or\n# country = df.Country\ncapital = df['Capital']\n# or\n# capital = df.Capital # displaying selected columns (Country and Capital)\nfor x, y in zip(country, capital): print(f\"{x} {y}\") # displaying a single column (Country)\nprint()\nprint(df['Population'])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Germany Berlin\nFrance Paris\nSpain Madrid\nItaly Rome\nIndia Delhi\nUSA Washington\nChina Beijing\nPoland Warsaw\nRussia Moscow\nEngland London 0 84,267,549\n1 65,534,239\n2 46,787,468\n3 60,301,346\n4 1,404,495,187\n5 334,506,463\n6 1,449,357,022\n7 37,771,789\n8 146,047,418\n9 68,529,747\nName: Population, dtype: object<\/pre>\n<p><strong>Explanation: <\/strong><\/p>\n<ul>\n<li>Read the csv file using <code>pd.read_csv()<\/code> Pandas function.<\/li>\n<li> Save all the information of the columns Country and Capital within independent variables using\n<ul>\n<li><code>country = df['Country']<\/code>\n<ul>\n<li>Alternatively, you can also use <code>country = df.Country<\/code><\/li>\n<\/ul>\n<\/li>\n<li><code>capital = df['Capital']<\/code>\n<ul>\n<li>Alternatively, you can also use <code>capital = df.Capital<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li>To display the country names and their capitals simultaneously, you can bind the two columns, <code>country<\/code> and <code>capital<\/code>, using the zip() function and then display each country along with its capital using a for loop upon the zipped object. <\/li>\n<li>To display all the values in the population column, you can simply use <code>df['Population']<\/code>.<\/li>\n<\/ul>\n<p><strong><span style=\"text-decoration: underline\">TRIVIA<\/span><\/strong><br \/><code>zip()<\/code>&nbsp;is a built-in function in Python that takes an arbitrary number of&nbsp;iterables&nbsp;and binds them into a single iterable, a <code>zip<\/code> object. It combines the&nbsp;<code>n-th<\/code>&nbsp;value of each iterable argument into a tuple.<br \/>Read more about <a href=\"https:\/\/blog.finxter.com\/python-ziiiiiiip-a-helpful-guide\/\" target=\"_blank\" rel=\"noreferrer noopener\">zip() <strong>here<\/strong><\/a>.<\/p>\n<h3><strong>\u27a4<\/strong> <strong>List-Based Indexing of a DataFrame<\/strong><\/h3>\n<p>In case you are not comfortable with using <code>zip()<\/code> to display multiple columns at once, you have another option. You can simply use list-based indexing to accomplish your goal. <\/p>\n<p>List-based indexing is a technique that allows you to pass multiple column names as a&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-lists\/\" target=\"_blank\">list&nbsp;<\/a>within the square-bracket selector. <\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"5\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd df = pd.read_csv(\"countries.csv\")\nprint()\nprint(df[['Country', 'Capital']])<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> Country Capital\n0 Germany Berlin\n1 France Paris\n2 Spain Madrid\n3 Italy Rome\n4 India Delhi\n5 USA Washington\n6 China Beijing\n7 Poland Warsaw\n8 Russia Moscow\n9 England London<\/pre>\n<h2><strong>Method 2: Integer Based Indexing with iloc<\/strong><\/h2>\n<p><strong>Approach: <\/strong>The idea here is to use the\u00a0<code>df.iloc[rows, columns].values<\/code>\u00a0to access individual columns from the DataFrame using indexing. Note that the first column always has the index 0, while the second column has index 1, and so on. <\/p>\n<ul>\n<li><code>rows<\/code> is used to select individual rows. Use the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/introduction-to-slicing-in-python\/\" target=\"_blank\">slicing colon<code>:<\/code><\/a>&nbsp;to ensure all rows have been selected.<\/li>\n<li><code>columns<\/code> is used to select individual columns.\n<ul>\n<li>Use <code>country = data.iloc[:, 0].values<\/code> to save the values of the Country column.<\/li>\n<li><code>capital = data.iloc[:, 1].values<\/code> to save the values of the Capital column.<\/li>\n<li><code>population = data.iloc[:, 2].values<\/code> to save the values of the Population column.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4-6\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd data = pd.read_csv('countries.csv')\ncountry = data.iloc[:, 0].values\ncapital = data.iloc[:, 1].values\npopulation = data.iloc[:, 2].values\n# displaying selected columns\nprint(data[['Country', 'Capital']])\nprint()\n# displaying a single column (Population)\nprint(population)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Country Capital\n0 Germany Berlin\n1 France Paris\n2 Spain Madrid\n3 Italy Rome\n4 India Delhi\n5 USA Washington\n6 China Beijing\n7 Poland Warsaw\n8 Russia Moscow\n9 England London ['84,267,549' '65,534,239' '46,787,468' '60,301,346' '1,404,495,187' '334,506,463' '1,449,357,022' '37,771,789' '146,047,418' '68,529,747']<\/pre>\n<h2><strong>Method 3: Name-Based Indexing with loc()<\/strong><\/h2>\n<p>Instead of selecting the columns by their index, you can also select them by their name using the <code>df.loc[]<\/code> selecter. <\/p>\n<p>The following example shows how to select the columns <code>Country<\/code> and <code>Capital<\/code> from the given DataFrame.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd data = pd.read_csv('countries.csv')\nval = data.loc[:, ['Country', 'Capital']]\nprint(val)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Country Capital\n0 Germany Berlin\n1 France Paris\n2 Spain Madrid\n3 Italy Rome\n4 India Delhi\n5 USA Washington\n6 China Beijing\n7 Poland Warsaw\n8 Russia Moscow\n9 England London<\/pre>\n<p class=\"has-base-background-color has-background\"><strong>Related Tutorial: <a href=\"https:\/\/blog.finxter.com\/slicing-data-from-a-pandas-dataframe-using-loc-and-iloc\/\" target=\"_blank\" rel=\"noreferrer noopener\">Slicing Data from a Pandas\u00a0DataFrame using .loc and .iloc<\/a><\/strong><\/p>\n<h2><strong>Method 4: Using csv Module<\/strong><\/h2>\n<p><code>csv<\/code> module is yet another spectacular option in Python that allows you to play with csv files. Let us have a look at the code that helps us to read the given csv file and then read specific columns from it:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import csv population = []\nwith open('countries.csv', newline='', encoding='utf-8-sig') as csvfile: data = csv.DictReader(csvfile) for r in data: print(\"Country\", \":\", \"Capital\") # append values from population column to population list population.append(r['Population']) # displaying specific columns (Country and Capital) print(r['Country'], \":\", r['Capital']) # display the population list print(population)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Country : Capital\nGermany : Berlin\nCountry : Capital\nFrance : Paris\nCountry : Capital\nSpain : Madrid\nCountry : Capital\nItaly : Rome\nCountry : Capital\nIndia : Delhi\nCountry : Capital\nUSA : Washington\nCountry : Capital\nChina : Beijing\nCountry : Capital\nPoland : Warsaw\nCountry : Capital\nRussia : Moscow\nCountry : Capital\nEngland : London\n['84,267,549', '65,534,239', '46,787,468', '60,301,346', '1,404,495,187', '334,506,463', '1,449,357,022', '37,771,789', '146,047,418', '68,529,747']<\/pre>\n<p><strong>Explanation:<\/strong><\/p>\n<ul>\n<li>Import the <code>csv<\/code> module and open up the csv file. Ensure that you feed in the <code>encoding<\/code> argument as it helps to eliminate any unreadable characters that may occur in the given csv file.\n<ul>\n<li><code>with open('countries.csv', newline='', encoding='utf-8-sig') as csvfile<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Allow Python to read the csv file as a dictionary using <code>csv.Dictreader<\/code> object. <\/li>\n<li>Once the file has been read in the form of a dictionary, you can easily fetch the values from respective columns by using the keys within square bracket notation from the dictionary. Here each column represents the key within the given dictionary.<\/li>\n<\/ul>\n<p><strong>Bonus: <\/strong>Here&#8217;s a quick look at how the <code>DictReader()<\/code> class looks like:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import csv population = []\nwith open('countries.csv', newline='', encoding='utf-8-sig') as csvfile: data = csv.DictReader(csvfile) for row in data: print(row)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>{'Country': 'Germany', 'Capital': 'Berlin', 'Population': '84,267,549', 'Area': '348,560'}\n{'Country': 'France', 'Capital': 'Paris', 'Population': '65,534,239', 'Area': '547,557'}\n{'Country': 'Spain', 'Capital': 'Madrid', 'Population': '46,787,468', 'Area': '498,800'}\n{'Country': 'Italy', 'Capital': 'Rome', 'Population': '60,301,346', 'Area': '294,140'}\n{'Country': 'India', 'Capital': 'Delhi', 'Population': '1,404,495,187', 'Area': '2,973,190'}\n{'Country': 'USA', 'Capital': 'Washington', 'Population': '334,506,463', 'Area': '9,147,420'}\n{'Country': 'China', 'Capital': 'Beijing', 'Population': '1,449,357,022', 'Area': '9,388,211'}\n{'Country': 'Poland', 'Capital': 'Warsaw', 'Population': '37,771,789', 'Area': '306,230'}\n{'Country': 'Russia', 'Capital': 'Moscow', 'Population': '146,047,418', 'Area': '16,376,870'}\n{'Country': 'England', 'Capital': 'London', 'Population': '68,529,747', 'Area': '241,930'}\n<\/code><\/pre>\n<p>It is evident from the output that <code>csv.DictReader()<\/code> returns a dictionary for each row such that the column header is the key while the value in the row is the associated value in the dictionary.<\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>To sum things up, there are majorly four different ways of accessing specific columns from a given csv file:<\/p>\n<ul>\n<li>List-Based Indexing.<\/li>\n<li>Integer-Based Indexing. <\/li>\n<li>Name-Based Indexing.<\/li>\n<li>Using csv modules <code>DictReader<\/code> class.<\/li>\n<\/ul>\n<p>Feel free to use the one that suits you best. I hope this tutorial helped you. Please <strong><a href=\"https:\/\/blog.finxter.com\/subscribe\" target=\"_blank\" rel=\"noreferrer noopener\">subscribe<\/a><\/strong> and stay tuned for more interesting tutorials. Happy learning!<\/p>\n<hr class=\"wp-block-separator\" \/>\n<h2>Learn Pandas the Fun Way by Solving Code Puzzles<\/h2>\n<p>If you want to boost your Pandas skills, consider checking out my puzzle-based learning book <a href=\"https:\/\/amzn.to\/3lyM5iZ\" title=\"https:\/\/amzn.to\/3lyM5iZ\" target=\"_blank\" rel=\"noreferrer noopener\">Coffee Break Pandas<\/a> (Amazon Link). <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/amzn.to\/3lyM5iZ\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/cover.jpg\" alt=\"Coffee Break Pandas Book\" class=\"wp-image-16780\" width=\"340\" height=\"511\" title=\"Coffee Break Pandas Book\" srcset=\"https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/cover.jpg 680w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/cover-200x300.jpg 200w, https:\/\/blog.finxter.com\/wp-content\/uploads\/2020\/11\/cover-150x225.jpg 150w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/><\/a><\/figure>\n<\/div>\n<p>It contains 74 hand-crafted Pandas puzzles including explanations. By solving each puzzle, you&#8217;ll get a score representing your skill level in Pandas. Can you become a Pandas Grandmaster?<\/p>\n<p><a href=\"https:\/\/amzn.to\/3lyM5iZ\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"https:\/\/amzn.to\/3lyM5iZ\">Coffee Break Pandas<\/a> offers a fun-based approach to data science mastery&#8212;and a truly gamified learning experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rate this post Table of Contents Method 1: Using Pandas \u27a4 List-Based Indexing of a DataFrame Method 2: Integer Based Indexing with iloc Method 3: Name-Based Indexing with loc() Method 4: Using csv Module Conclusion Learn Pandas the Fun Way by Solving Code Puzzles A Quick Glance at The Solutions [Each solution stays for 5-10 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-124576","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=124576"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124576\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=124576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=124576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=124576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}