

{"id":56921,"date":"2019-05-29T11:49:14","date_gmt":"2019-05-29T06:19:14","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=56921"},"modified":"2019-05-31T12:19:45","modified_gmt":"2019-05-31T06:49:45","slug":"pandas-dataframe","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/","title":{"rendered":"Pandas DataFrame Tutorial &#8211;  A Complete Guide (Don&#8217;t Miss the Opportunity)"},"content":{"rendered":"<p>Pandas DataFrame is the Data Structure, which is\u00a0a 2 dimensional Array. One can say that <em><strong>multiple Pandas Series<\/strong> <strong>make a Pandas DataFrame<\/strong><\/em>. DataFrames are visually represented in the form of a table. DataFrames are one of the most integral data structure and one can\u2019t\u00a0simply proceed to learn Pandas without learning DataFrames first.<\/p>\n<p><strong>Parameters of DataFrames in Pandas<\/strong><\/p>\n<ul>\n<li><strong>data<\/strong> &#8211; The data from which the dataframe will be made<\/li>\n<li><strong>index<\/strong> &#8211; States the index from dataframe<\/li>\n<li><strong>columns<\/strong> &#8211; States the column label<\/li>\n<li><strong>dtype<\/strong> &#8211; The datatype for the dataframe<\/li>\n<li><strong>copy<\/strong> &#8211; Any copied data taken from inputs<\/li>\n<\/ul>\n<p>In this Pandas Dataframe tutorial, we are going to study everything about dataframes like creating, renaming, deleting, transposing, etc.<\/p>\n<p><em><strong>So, don&#8217;t waste your time and get ready to dive into an ocean of information.<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57129\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg\" alt=\"Example of Pandas DataFrames\" width=\"802\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes-520x272.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h2>1. How to Create Pandas DataFrame from the dictionary?<\/h2>\n<p>We start by importing the pandas library<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import pandas as pd\r\n&gt;&gt;&gt; import numpy as np<\/pre>\n<p><em><strong>To become an expert in Pandas, you should be aware of <a href=\"https:\/\/data-flair.training\/blogs\/basic-functionality-in-pandas\/\">Pandas Basic Functionalities<\/a><\/strong><\/em><\/p>\n<p>To create a DataFrame in Pandas from a dict, we first need to make a dict. For that, we will use the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; data={'student': ['Jack','Mike','Rohan','Zubair'], 'year':[1,2,3,1], 'marks':[9.8,6.7,8,9.9]}<\/pre>\n<p>After this is done, all we have to do to make a DataFrame is to use the following commands:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df=pd.DataFrame(data)\r\n&gt;&gt;&gt; dataflair_df<\/pre>\n<p>The first line of code makes the DataFrame while the second one simply prints the entire thing out. We will get an out like this:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56946\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame.jpg\" alt=\"How to Create a pandas Dataframes\" width=\"1366\" height=\"702\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame-150x77.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame-300x154.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame-768x395.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame-1024x526.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-Pandas-DataFrame-520x267.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h2>2. How to Access Last and First Rows of DataFrame in Pandas?<\/h2>\n<p>Using <strong>.head()<\/strong> and <strong>.tail()<\/strong>, we have been able to access the first few rows and the last few rows. In both cases, without a parameter, we will get 2 rows. Let\u2019s continue with the help of examples:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df.head(2)<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56947\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas.jpg\" alt=\"Performing Pandas Head Function on dataframes\" width=\"1363\" height=\"686\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas.jpg 1363w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas-150x75.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas-300x151.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas-768x387.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas-1024x515.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Head-Function-in-Pandas-520x262.jpg 520w\" sizes=\"auto, (max-width: 1363px) 100vw, 1363px\" \/><\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df.tail(2)<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56948\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas.jpg\" alt=\"Pandas Tail Function on Dataframes\" width=\"1366\" height=\"676\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas-150x74.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas-300x148.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas-768x380.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas-1024x507.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Tail-Function-in-Pandas-520x257.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p><strong><em>Get the easy steps to <a href=\"https:\/\/data-flair.training\/blogs\/sort-pandas-dataframes-series-array\/\">Sort Pandas Dataframes and Series<\/a><\/em><\/strong><\/p>\n<h2>3. How to\u00a0Change the Column in Pandas DataFrame?<\/h2>\n<p>As we can see, the DataFrame is not representing our content according to the column order, we gave in the dictionary. Therefore the following method is used:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_d=pd.DataFrame(data, columns=['student','marks','year'])\r\n&gt;&gt;&gt; dataflair_d<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57065\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames.jpg\" alt=\"How to change the column in dataframes\" width=\"1366\" height=\"660\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames-300x145.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames-768x371.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames-1024x495.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Change-the-coloumn-in-Pandas-DataFrames-520x251.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h2>4. How to Access the Columns in Pandas DataFrame?<\/h2>\n<p>Columns can be accessed in two ways:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_d['year']<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-56955 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames.jpg\" alt=\"Access Columns in DataFrames\" width=\"1366\" height=\"624\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames-150x69.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames-300x137.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames-768x351.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames-1024x468.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-Columns-in-DataFrames-520x238.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p><strong>Or we can also access columns as an attribute:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_d.student<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56957\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe.jpg\" alt=\"Access the Columns in Pandas Dataframe by access columns as an attribute\" width=\"1366\" height=\"649\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe-150x71.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe-300x143.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe-768x365.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe-1024x487.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-Columns-in-Pandas-Dataframe-520x247.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<h2>5. How to Access the Rows in DataFrames?<\/h2>\n<p>We use <strong>loc and iloc functions<\/strong> to access rows. Here is an example of how that works:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_d.loc[2]<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56956\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe.jpg\" alt=\"Access the rows in Pandas Dataframe\" width=\"1365\" height=\"661\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe-150x73.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe-300x145.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe-768x372.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe-1024x496.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Access-the-rows-in-Pandas-Dataframe-520x252.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>Here, we see that the loc function returns the values of the row needed along with the column names attributed to each value. This is a very helpful function.<\/p>\n<h2>6. Various Assignments and Operations on Pandas DataFrame<\/h2>\n<p>Let\u2019s create a second DataFrame and this time, in the column attribute, let\u2019s add a column that was not present in our dictionary.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df2= pd.DataFrame(data, columns=['student','marks','year','subjects'])\r\n&gt;&gt;&gt; dataflair_df2<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56959\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame.jpg\" alt=\"Assignments and Operations on a DataFrame\" width=\"1366\" height=\"634\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame-300x139.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame-768x356.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame-1024x475.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Assignments-and-Operations-on-a-Pandas-DataFrame-520x241.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>The column \u2018subject\u2019 was never a part of out original dictionary. Let\u2019s see how Pandas handles this:<\/p>\n<p>Pandas took all the values of the column \u2018subject\u2019 to be missing values and thus represented them as \u2018NaN\u2019<\/p>\n<p>A <a href=\"https:\/\/data-flair.training\/blogs\/python-pandas-features\/\"><strong>cool feature of Pandas<\/strong> <\/a>is that you assign a column with a certain constant value. For example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df2['subjects']=4\r\n&gt;&gt;&gt; dataflair_df2<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57067\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign.jpg\" alt=\"Pandas Column in Dataframes \" width=\"1364\" height=\"646\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign.jpg 1364w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-150x71.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-300x142.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-768x364.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-1024x485.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-520x246.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-Coloumn-assign-720x340.jpg 720w\" sizes=\"auto, (max-width: 1364px) 100vw, 1364px\" \/><\/a><\/p>\n<p>This will give us a DataFrame with the subject column containing just the value of 4 for every row.<\/p>\n<p>We can also map series onto a column in a DataFrame. To see how that works, let us first create a series.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; ser=pd.Series([2,3,],index=[1,3])<\/pre>\n<p>Then we will map it onto our \u2018subject\u2019 column:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df2['subjects']=ser\r\n&gt;&gt;&gt; dataflair_df2<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56961\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame.jpg\" alt=\"Map series onto a column in a DataFrame\" width=\"1366\" height=\"607\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame-150x67.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame-300x133.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame-768x341.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame-1024x455.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/map-series-onto-a-column-in-a-DataFrame-520x231.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>From the above output, 1 and 3 consider as an index for the values of the series. When pandas dataframes mapped columns make sure they only occupy the indices, which were mentioned.\u00a0The indices that were not mentioned, get a missing value as their value.<\/p>\n<p>We can also perform boolean assignments on operators. Let\u2019s take a new column called \u2018grades\u2019<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df2['grade']=dataflair_df2.marks&gt;8\r\n&gt;&gt;&gt; dataflair_df2<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56962\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames.jpg\" alt=\"Boolean Operators perform on Pandas DataFrames\" width=\"1366\" height=\"659\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames.jpg 1366w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames-300x145.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames-768x371.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames-1024x494.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Boolean-Operators-perform-on-Pandas-DataFrames-520x251.jpg 520w\" sizes=\"auto, (max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>What this does is, it creates a new column \u2018grade\u2019 and fills each value of the column with a boolean expression that is returned when df.marks&gt;8 is evaluated for each row. The boolean value can either be True or False.<\/p>\n<p>Here we see, 6 and 7 gives the false value because both these numbers are not greater than 8<\/p>\n<p><em><strong>It&#8217;s the right time to\u00a0<a href=\"https:\/\/data-flair.training\/blogs\/pandas-options-and-customizations\/\">Customize your data with Pandas Options\u00a0<\/a><\/strong><\/em><\/p>\n<h2>7. How to Delete Columns in\u00a0Pandas\u00a0DataFrame?<\/h2>\n<p>To delete a column in Pandas Dataframes, all we need to do is use the <strong>command del<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del dataflair_df2['grade']\r\n&gt;&gt;&gt; dataflair_df2<\/pre>\n<p><strong>This will give us:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57068\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes.jpg\" alt=\"Delete Column in DataFrames\" width=\"1365\" height=\"624\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes-150x69.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes-300x137.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes-768x351.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes-1024x468.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Columns-in-Pandas-Dataframes-520x238.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>8.\u00a0How to Delete Rows in Pandas DataFrame?<\/h2>\n<p>Pandas use<strong> .drop function<\/strong> to remove rows and columns.<\/p>\n<p>To remove rows according to the index we will do the following:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df.drop(['one'])<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<h2><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57112\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes.jpg\" alt=\"Delete Rows in DataFrames\" width=\"1365\" height=\"590\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes-150x65.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes-300x130.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes-768x332.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes-1024x443.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Delete-Rows-in-Pandas-Dataframes-520x225.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/h2>\n<h2>9. Pandas DataFrame with Nested Dictionaries<\/h2>\n<p>Let us consider a nested dictionary:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dict={'fruits':{'apple':40,'orange':20,'bananas':25,'grapes':30}, 'vegetables':{'carrot':20,'beans':16,'peas':30,'onion':25}}<\/pre>\n<p>In this dictionary, we see two dictionaries, \u2018fruits\u2019 and \u2018vegetables\u2019. These two dictionaries will get a column to their name. Let\u2019s see, what happens when putting in a DataFrame:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df3=pd.DataFrame(dict)\r\n&gt;&gt;&gt; dataflair_df3<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57069\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries.jpg\" alt=\"Pandas DataFrames with Nested Dictionaries\" width=\"1365\" height=\"652\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries-300x143.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries-768x367.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries-1024x489.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-DataFrames-with-Nested-Dictionaries-520x248.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>Therefore, we get Pandas DataFrame which uses all the members of the nested dictionaries. The members of one dictionary, which are not present in the other, gets represented as a Missing Value for the dictionary they aren\u2019t present in.<\/p>\n<p>For example, apple is present in the dictionary fruits, not in vegetables. Therefore in column fruits, it has the value pertaining to it in the dictionary, while vegetable column gets a NaN for apple.<\/p>\n<h2>10. How to Transpose Pandas DataFrames?<\/h2>\n<p>We can easily Transpose a Dataframe using the following method.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df3.T<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57070\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes.jpg\" alt=\"Transpose a Dataframe\" width=\"1365\" height=\"652\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes-300x143.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes-768x367.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes-1024x489.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Transposing-pandas-dataframes-520x248.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>11. Iterating over the Rows and Columns of Dataframe<\/h2>\n<p>We first make a new Pandas dataframe:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt; dataflair_new= { 'fruit': [\"Guava\", \"Apple\", \"Oranges\"], 'price':[40, 120, 60]}\r\n&gt;&gt;&gt; dataflair_df= pd.DataFrame(dataflair_new)\r\n&gt;&gt;&gt; dataflair_df<\/pre>\n<p>Then we iterate over the rows using the <strong>iterrows() function<\/strong>.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; for i, j in dataflair_df.iterrows():\r\n... print(i,j)\r\n... print()\r\n...<\/pre>\n<p><strong>There are 3 ways to iterate over DataFrames, get complete details for <a href=\"https:\/\/data-flair.training\/blogs\/iteration-in-pandas\/\">Iteration in Pandas with example<\/a>.<\/strong><\/p>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57097\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas.jpg\" alt=\"iterrows() function in Pandas\" width=\"1365\" height=\"636\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas-300x140.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas-768x358.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas-1024x477.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iterrows-function-in-Pandas-520x242.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>We can also iterate column-wise <strong>using iteritems() Function.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; for i, j in dataflair_df.iteritems():\r\n... print(i,j)\r\n... print()\r\n...<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57098\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas.jpg\" alt=\"iteritems function in Pandas\" width=\"1365\" height=\"660\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas-150x73.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas-300x145.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas-768x371.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas-1024x495.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/iteritems-function-in-Pandas-520x251.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>12. How to Rename a Column in Pandas DataFrames?<\/h2>\n<p>We can rename columns using the<strong> .rename() function.<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df.rename(index=str, columns={\"fruit\": \"a\", \"price\": \"c\"})<\/pre>\n<p>In the parameters of the .rename function, we have declared a dictionary stating the change we want. The original name is mentioned as a key of the dictionary and the desired change is given as the value to that key.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57099\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes.jpg\" alt=\"Renaming a pandas Dataframes\" width=\"1365\" height=\"657\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes-150x72.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes-300x144.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes-768x370.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes-1024x493.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Rename-a-pandas-Dataframes-520x250.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>13. Stacking and Unstacking of DataFrames<\/h2>\n<p>Using the .stack() function we can get a long version of a wide table dataframe.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_st=dataflair_df.stack()\r\n&gt;&gt;&gt; dataflair_st<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57100\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames.jpg\" alt=\"Stacking in Pandas DataFrames\" width=\"1362\" height=\"670\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames.jpg 1362w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames-150x74.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames-300x148.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames-768x378.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames-1024x504.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Stacking-in-Pandas-DataFrames-520x256.jpg 520w\" sizes=\"auto, (max-width: 1362px) 100vw, 1362px\" \/><\/a><\/p>\n<p>We can unstack this stacked data using the <strong>.unstack function<\/strong>.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57101\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames.jpg\" alt=\"Unstacking in Pandas DataFrames\" width=\"1362\" height=\"633\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames.jpg 1362w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames-300x139.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames-768x357.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames-1024x476.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Unstacking-in-Pandas-DataFrames-520x242.jpg 520w\" sizes=\"auto, (max-width: 1362px) 100vw, 1362px\" \/><\/a><\/p>\n<h2>14. Setting a List as an Index in Pandas DataFrames<\/h2>\n<p>We can set a<a href=\"https:\/\/data-flair.training\/blogs\/python-list-examples\/\"> <strong>python list<\/strong><\/a> to be the index for the dataframe. But we need to make sure that the list contains the same number of elements as the number of indices already present in the DataFrame.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; id=['one','two', 'three']\r\n&gt;&gt;&gt; dataflair_df.index= id\r\n&gt;&gt;&gt; dataflair_df<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames-.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57103\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames-.jpg\" alt=\"Setting a List as an Index in Pandas DataFrames\u00a0\" width=\"1365\" height=\"625\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames-.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--150x69.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--300x137.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--768x352.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--1024x469.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--980x450.jpg 980w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Setting-a-List-as-an-Index-in-Pandas-DataFrames--520x238.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>15. Selecting values from a DataFrame according to index<\/h2>\n<p>We can use the <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.DataFrame.loc.html\">.loc[] function<\/a> to select data from a Dataframe according to index.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_df.loc['one']<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57104\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes.jpg\" alt=\"Selecting values from a DataFrame according to index\" width=\"1365\" height=\"677\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes-150x74.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes-300x149.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes-768x381.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes-1024x508.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Select-value-from-pandas-dataframes-520x258.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>16. Working with Missing Values<\/h2>\n<p>Missing values in Pandas Dataframes are represented using NaN. There are methods to work around such missing data to make a more optimized dataset<\/p>\n<p>Create a dataset like the following:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_dict={'Data':[1, np.nan, 8, 9, np.nan], 'name':[\"Ron\",\"Harry\",\"Hermione\",\"Neville\",\"Dobby\"]}\r\n&gt;&gt;&gt; dataflair_pdx= pd.DataFrame(dataflair_dict)\r\n&gt;&gt;&gt; dataflair_pdx<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57108\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes.jpg\" alt=\"Create a dataset\" width=\"1365\" height=\"641\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes-150x70.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes-300x141.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes-768x361.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes-1024x481.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Create-a-dataset-in-Pandas-Dataframes-520x244.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>We can generate a boolean table which gives us the value True for every data which is missing.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_pdx.isnull()<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57109\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table.jpg\" alt=\"Generate a boolean table\" width=\"1365\" height=\"669\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table-150x74.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table-300x147.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table-768x376.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table-1024x502.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Generate-a-boolean-table-520x255.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>To replace the missing data with a constant value of our choice, we use .fillna()<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_pdx.fillna('Not avaliable')<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57110\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe.jpg\" alt=\"replace a missing data\" width=\"1365\" height=\"646\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-150x71.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-300x142.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-768x363.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-1024x485.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-520x246.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/replace-a-missing-data-in-pandas-dataframe-720x340.jpg 720w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<p>We can drop all data which is missing using .dropna() function<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; dataflair_pdx.dropna()<\/pre>\n<p><strong>Output-<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57111\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function.jpg\" alt=\"Pandas dropna function\" width=\"1365\" height=\"629\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function.jpg 1365w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function-150x69.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function-300x138.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function-768x354.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function-1024x472.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dropna-function-520x240.jpg 520w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><\/a><\/p>\n<h2>17. Summary<\/h2>\n<p>We have gone through all the different functions and capabilities of a DataFrame. This is a very essential part of the Pandas Library and it is absolutely necessary to understand all the things taught.<\/p>\n<p><em><strong>Don&#8217;t forget to check the <a href=\"https:\/\/data-flair.training\/blogs\/applications-of-pandas\/\">latest Applications of Pandas in real-world<\/a>.<\/strong><\/em><\/p>\n<p>Comments are the best way to present your feedback. Therefore, don&#8217;t forget to comment below.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1529,&quot;href&quot;:&quot;https:\\\/\\\/pandas.pydata.org\\\/pandas-docs\\\/stable\\\/reference\\\/api\\\/pandas.DataFrame.loc.html&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20250927040715\\\/https:\\\/\\\/pandas.pydata.org\\\/pandas-docs\\\/stable\\\/reference\\\/api\\\/pandas.DataFrame.loc.html&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 10:36:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-18 05:22:21&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-07 10:40:29&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-15 09:01:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-20 00:09:40&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-31 08:42:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 12:13:07&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-19 17:20:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-23 02:53:00&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-08 17:00:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-22 03:23:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-22 16:19:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-01 13:28:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-08 06:15:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-13 09:48:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-20 06:43:20&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-20 06:43:20&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pandas DataFrame is the Data Structure, which is\u00a0a 2 dimensional Array. One can say that multiple Pandas Series make a Pandas DataFrame. DataFrames are visually represented in the form of a table. DataFrames are&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":57129,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19475],"tags":[19940,19941,19943,19944,19939,19938,19942],"class_list":["post-56921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pandas","tag-create-pandas-dataframe","tag-delete-pandas-dataframe","tag-index-pandas-dataframe","tag-pandas-dataframe-transpose","tag-pandas-dataframe-tutorial","tag-pandas-dataframes","tag-rename-pandas-dataframe"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pandas DataFrame Tutorial - A Complete Guide (Don&#039;t Miss the Opportunity) - DataFlair<\/title>\n<meta name=\"description\" content=\"pandas Dataframe is the collection of series. Learn everything about Dataframes - create, delete, rename, index, change the column &amp; rows, iteration, Transpose, Stacking, Unstacking on dataframes\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pandas DataFrame Tutorial - A Complete Guide (Don&#039;t Miss the Opportunity) - DataFlair\" \/>\n<meta property=\"og:description\" content=\"pandas Dataframe is the collection of series. Learn everything about Dataframes - create, delete, rename, index, change the column &amp; rows, iteration, Transpose, Stacking, Unstacking on dataframes\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-29T06:19:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-31T06:49:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pandas DataFrame Tutorial - A Complete Guide (Don't Miss the Opportunity) - DataFlair","description":"pandas Dataframe is the collection of series. Learn everything about Dataframes - create, delete, rename, index, change the column & rows, iteration, Transpose, Stacking, Unstacking on dataframes","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:\/\/data-flair.training\/blogs\/pandas-dataframe\/","og_locale":"en_US","og_type":"article","og_title":"Pandas DataFrame Tutorial - A Complete Guide (Don't Miss the Opportunity) - DataFlair","og_description":"pandas Dataframe is the collection of series. Learn everything about Dataframes - create, delete, rename, index, change the column & rows, iteration, Transpose, Stacking, Unstacking on dataframes","og_url":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-05-29T06:19:14+00:00","article_modified_time":"2019-05-31T06:49:45+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Pandas DataFrame Tutorial &#8211; A Complete Guide (Don&#8217;t Miss the Opportunity)","datePublished":"2019-05-29T06:19:14+00:00","dateModified":"2019-05-31T06:49:45+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/"},"wordCount":1230,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg","keywords":["Create Pandas DataFrame","Delete Pandas DataFrame","Index Pandas DataFrame","Pandas DataFrame Transpose","Pandas DataFrame tutorial","Pandas DataFrames","Rename Pandas DataFrame"],"articleSection":["Pandas Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/","url":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/","name":"Pandas DataFrame Tutorial - A Complete Guide (Don't Miss the Opportunity) - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg","datePublished":"2019-05-29T06:19:14+00:00","dateModified":"2019-05-31T06:49:45+00:00","description":"pandas Dataframe is the collection of series. Learn everything about Dataframes - create, delete, rename, index, change the column & rows, iteration, Transpose, Stacking, Unstacking on dataframes","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/pandas-dataframe\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/05\/Pandas-dataframes.jpg","width":802,"height":420,"caption":"Example of Pandas DataFrames"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/pandas-dataframe\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Pandas Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/pandas\/"},{"@type":"ListItem","position":3,"name":"Pandas DataFrame Tutorial &#8211; A Complete Guide (Don&#8217;t Miss the Opportunity)"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/56921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=56921"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/56921\/revisions"}],"predecessor-version":[{"id":57310,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/56921\/revisions\/57310"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/57129"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=56921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=56921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=56921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}