{"id":25526048,"date":"2022-05-29T22:23:36","date_gmt":"2022-05-29T16:53:36","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25526048"},"modified":"2022-11-22T17:13:58","modified_gmt":"2022-11-22T11:43:58","slug":"different-ways-of-creating-dataframe-with-python","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/","title":{"rendered":"Different Ways of Creating DataFrame With Python"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69ea1c7228af5\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69ea1c7228af5\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#Different_methods_of_Creating_DataFrame\" >Different methods of Creating DataFrame<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#How_to_create_new_variables_in_the_data_frame\" >How to create new variables in the data frame<\/a><\/li><\/ul><\/nav><\/div>\n<p>A Data Frame is a two-dimension collection of data. It is a data structure where data is stored in tabular form. Datasets are arranged in rows and columns; we can store multiple datasets in the data frame. We can perform various arithmetic operations, such as adding column\/row selection and columns\/rows in the data frame.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<p>We can import the DataFrames from the external storage; these storages can be referred to as the\u00a0SQL. \u00a0A data frame consists of index, column names and the data itself. The index is like a label for each row and together with the column names acts as an address to each data element. The data in a DataFrame can be heterogeneous, i.e., they can be of different data types.<\/p>\n<p>Database, CSV file, and an Excel file. We can also use the lists, dictionary, and from a list of dictionary, etc.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Different_methods_of_Creating_DataFrame\"><\/span><strong>Different methods of Creating DataFrame<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><strong>An empty dataframe<\/strong><\/h3>\n<p>We can create a basic empty Dataframe. The dataframe constructor needs to be called to create the DataFrame. Let&#8217;s understand the following example.<\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>#\u00a0<strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>#\u00a0Calling\u00a0DataFrame\u00a0constructor<\/p>\n<p>df\u00a0=\u00a0pd.DataFrame()<\/p>\n<p>print(df)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>Empty DataFrame<\/p>\n<p>Columns: []\n<p>Index: []\n<h3><strong>Create a dataframe using List<\/strong><\/h3>\n<p>We can create dataframe using a single list or list of lists. Let&#8217;s understand the following example.<\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0importing\u00a0pandas\u00a0library<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0string\u00a0values\u00a0in\u00a0the\u00a0list<\/p>\n<p>lst\u00a0=\u00a0[&#8216;Java&#8217;,\u00a0&#8216;Python&#8217;,\u00a0&#8216;C&#8217;,\u00a0&#8216;C++&#8217;,<\/p>\n<p>&#8216;JavaScript&#8217;,\u00a0&#8216;Swift&#8217;,\u00a0&#8216;Go&#8217;]\n<p>&nbsp;<\/p>\n<p>#\u00a0Calling\u00a0DataFrame\u00a0constructor\u00a0on\u00a0list<\/p>\n<p>dframe\u00a0=\u00a0pd.DataFrame(lst)<\/p>\n<p>print(dframe)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Java1\u00a0\u00a0\u00a0\u00a0\u00a0 Python2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 C3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 C++4\u00a0\u00a0 JavaScript5\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Swift6\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Go<\/p>\n<h3><strong>Create Dataframe from dict of ndarray\/lists<\/strong><\/h3>\n<p>The dict of ndarray\/lists can be used to create a dataframe, all the\u00a0<strong>ndarray<\/strong>\u00a0must be of the same length. The index will be a range(n) by default; where n denotes the array length. Let&#8217;s understand the following example.<\/p>\n<p><strong>Example <\/strong><\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0assign\u00a0data\u00a0of\u00a0lists.<\/p>\n<p>data\u00a0=\u00a0{&#8216;Name&#8217;:\u00a0[&#8216;Tom&#8217;,\u00a0&#8216;Joseph&#8217;,\u00a0&#8216;Krish&#8217;,\u00a0&#8216;John&#8217;],\u00a0&#8216;Age&#8217;:\u00a0[20,\u00a021,\u00a019,\u00a018]}<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Create\u00a0DataFrame<\/p>\n<p>df\u00a0=\u00a0pd.DataFrame(data)<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Print\u00a0the\u00a0output.<\/p>\n<p>print(df)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>Name\u00a0 Age0\u00a0\u00a0\u00a0\u00a0 Tom\u00a0\u00a0 201\u00a0 Joseph\u00a0\u00a0 212\u00a0\u00a0 Krish\u00a0\u00a0 193\u00a0\u00a0\u00a0 John\u00a0\u00a0 18<\/p>\n<h3><strong>Create a indexes Dataframe using arrays<\/strong><\/h3>\n<p>Let&#8217;s understand the following example to create the indexes dataframe using arrays.<\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>#\u00a0DataFrame\u00a0using\u00a0arrays.<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0assign\u00a0data\u00a0of\u00a0lists.<\/p>\n<p>data\u00a0=\u00a0{&#8216;Name&#8217;:[&#8216;Renault&#8217;,\u00a0&#8216;Duster&#8217;,\u00a0&#8216;Maruti&#8217;,\u00a0&#8216;Honda\u00a0City&#8217;],\u00a0&#8216;Ratings&#8217;:[9.0,\u00a08.0,\u00a05.0,\u00a03.0]}<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Creates\u00a0pandas\u00a0DataFrame.<\/p>\n<p>df\u00a0=\u00a0pd.DataFrame(data,\u00a0index\u00a0=[&#8216;position1&#8217;,\u00a0&#8216;position2&#8217;,\u00a0&#8216;position3&#8217;,\u00a0&#8216;position4&#8217;])<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0print\u00a0the\u00a0data<\/p>\n<p>print(df)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>Name\u00a0\u00a0\u00a0\u00a0\u00a0 Ratingsposition1\u00a0\u00a0\u00a0\u00a0 Renault\u00a0\u00a0\u00a0\u00a0\u00a0 9.0position2\u00a0\u00a0\u00a0\u00a0\u00a0 Duster\u00a0\u00a0\u00a0\u00a0\u00a0 8.0position3\u00a0\u00a0\u00a0\u00a0\u00a0 Maruti\u00a0\u00a0\u00a0\u00a0\u00a0 5.0position4\u00a0\u00a0\u00a0 Honda City\u00a0\u00a0\u00a0\u00a0\u00a0 3.0<\/p>\n<p>In the above code, we have defined the column name with the various car names and their ratings. We used the array to create indexes.<\/p>\n<h3><strong>Create Dataframe from list of dicts<\/strong><\/h3>\n<p>We can pass the lists of dictionaries as input data to create the Pandas dataframe. The column names are taken as keys by default. Let&#8217;s understand the following example.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>#\u00a0the\u00a0example\u00a0is\u00a0to\u00a0create<\/p>\n<p>#\u00a0Pandas\u00a0DataFrame\u00a0by\u00a0lists\u00a0of\u00a0dicts.<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0assign\u00a0values\u00a0to\u00a0lists.<\/p>\n<p>data\u00a0=\u00a0[{&#8216;A&#8217;:\u00a010,\u00a0&#8216;B&#8217;:\u00a020,\u00a0&#8216;C&#8217;:30},\u00a0{&#8216;x&#8217;:100,\u00a0&#8216;y&#8217;:\u00a0200,\u00a0&#8216;z&#8217;:\u00a0300}]\n<p>&nbsp;<\/p>\n<p>#\u00a0Creates\u00a0DataFrame.<\/p>\n<p>df\u00a0=\u00a0pd.DataFrame(data)<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Print\u00a0the\u00a0data<\/p>\n<p>print(df)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>A\u00a0\u00a0\u00a0\u00a0\u00a0 B\u00a0\u00a0\u00a0\u00a0\u00a0 C\u00a0\u00a0\u00a0\u00a0\u00a0 x\u00a0\u00a0\u00a0\u00a0\u00a0 y\u00a0\u00a0\u00a0\u00a0\u00a0 z0\u00a0 10.0\u00a0 20.0\u00a0 30.0\u00a0\u00a0\u00a0 NaN\u00a0\u00a0\u00a0 NaN\u00a0\u00a0\u00a0 NaN1\u00a0\u00a0 NaN\u00a0\u00a0 NaN\u00a0\u00a0 NaN\u00a0 100.0\u00a0 200.0\u00a0 300.0<\/p>\n<h3><strong>Create Dataframe using the zip() function<\/strong><\/h3>\n<p>The zip() function is used to merge the two lists. Let&#8217;s understand the following example.<\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>#\u00a0The\u00a0example\u00a0is\u00a0to\u00a0create<\/p>\n<p>#\u00a0pandas\u00a0dataframe\u00a0from\u00a0lists\u00a0using\u00a0zip.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0List1<\/p>\n<p>Name\u00a0=\u00a0[&#8216;tom&#8217;,\u00a0&#8216;krish&#8217;,\u00a0&#8216;arun&#8217;,\u00a0&#8216;juli&#8217;]\n<p>&nbsp;<\/p>\n<p>#\u00a0List2<\/p>\n<p>Marks\u00a0=\u00a0[95,\u00a063,\u00a054,\u00a047]\n<p>&nbsp;<\/p>\n<p>#\u00a0\u00a0two\u00a0lists.<\/p>\n<p>#\u00a0and\u00a0merge\u00a0them\u00a0by\u00a0using\u00a0zip().<\/p>\n<p>list_tuples\u00a0=\u00a0list(zip(Name,\u00a0Marks))<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Assign\u00a0data\u00a0to\u00a0tuples.<\/p>\n<p>print(list_tuples)<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Converting\u00a0lists\u00a0of\u00a0tuples\u00a0into<\/p>\n<p>#\u00a0pandas\u00a0Dataframe.<\/p>\n<p>dframe\u00a0=\u00a0pd.DataFrame(list_tuples,\u00a0columns=[&#8216;Name&#8217;,\u00a0&#8216;Marks&#8217;])<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Print\u00a0data.<\/p>\n<p>print(dframe)<\/p>\n<p><strong>Output:<\/strong><\/p>\n[(&#8216;john&#8217;, 95), (&#8216;krish&#8217;, 63), (&#8216;arun&#8217;, 54), (&#8216;juli&#8217;, 47)]\u00a0\u00a0\u00a0 Name\u00a0 Marks0\u00a0\u00a0 john\u00a0\u00a0\u00a0\u00a0 951\u00a0 krish\u00a0\u00a0\u00a0\u00a0 632\u00a0\u00a0 arun\u00a0\u00a0\u00a0\u00a0 543\u00a0\u00a0 juli\u00a0\u00a0\u00a0\u00a0 47<\/p>\n<h3><strong>Create Dataframe from Dicts of series<\/strong><\/h3>\n<p>The dictionary can be passed to create a dataframe. We can use the Dicts of series where the subsequent index is the union of all the series of passed index value. Let&#8217;s understand the following example.<\/p>\n<p><strong>Example &#8211;<\/strong><\/p>\n<p>#\u00a0Pandas\u00a0Dataframe\u00a0from\u00a0Dicts\u00a0of\u00a0series.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>import<\/strong>\u00a0pandas\u00a0as\u00a0pd<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0Initialize\u00a0data\u00a0to\u00a0Dicts\u00a0of\u00a0series.<\/p>\n<p>d\u00a0=\u00a0{&#8216;Electronics&#8217;\u00a0:\u00a0pd.Series([97,\u00a056,\u00a087,\u00a045],\u00a0index\u00a0=[&#8216;John&#8217;,\u00a0&#8216;Abhinay&#8217;,\u00a0&#8216;Peter&#8217;,\u00a0&#8216;Andrew&#8217;]),<\/p>\n<p>&#8216;Civil&#8217;\u00a0:\u00a0pd.Series([97,\u00a088,\u00a044,\u00a096],\u00a0index\u00a0=[&#8216;John&#8217;,\u00a0&#8216;Abhinay&#8217;,\u00a0&#8216;Peter&#8217;,\u00a0&#8216;Andrew&#8217;])}<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0creates\u00a0Dataframe.<\/p>\n<p>dframe\u00a0=\u00a0pd.DataFrame(d)<\/p>\n<p>&nbsp;<\/p>\n<p>#\u00a0print\u00a0the\u00a0data.<\/p>\n<p>print(dframe)<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p>Electronics\u00a0\u00a0\u00a0\u00a0\u00a0 CivilJohn\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 97\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 97Abhinay\u00a0\u00a0\u00a0\u00a0\u00a0 56\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 88Peter\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 87\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 44Andrew\u00a0\u00a0\u00a0\u00a0\u00a0 45\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 96<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_create_new_variables_in_the_data_frame\"><\/span><strong>How to create new variables in the data frame<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Creating a new variable in pandas data frame is an easy task! Either you can pass the values of that new column or you can generate the values of new columns based on the existing columns.<\/p>\n<p>The code snippet shown below creates two new columns based on the Age column.<\/p>\n<table width=\"596\">\n<tbody>\n<tr>\n<td width=\"596\"># Defining Employee Data<\/p>\n<p>import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<p>EmployeeData=pd.DataFrame({&#8216;Name&#8217;: [&#8216;ram&#8217;,&#8217;ravi&#8217;,&#8217;sham&#8217;,&#8217;sita&#8217;,&#8217;gita&#8217;],<\/p>\n<p>&#8216;id&#8217;: [101,102,103,104,105],<\/p>\n<p>&#8216;Gender&#8217;: [&#8216;M&#8217;,&#8217;M&#8217;,&#8217;M&#8217;,&#8217;F&#8217;,&#8217;F&#8217;],<\/p>\n<p>&#8216;Age&#8217;: [21,25,24,28,25]\n<p>})<\/p>\n<p># Priting data<\/p>\n<p>print(EmployeeData)<\/p>\n<p>&nbsp;<\/p>\n<p># Creating a new variable in data based on existing variable<\/p>\n<p>EmployeeData[&#8216;NewAge&#8217;]= EmployeeData[&#8216;Age&#8217;] + 10<\/p>\n<p>&nbsp;<\/p>\n<p># Priting data<\/p>\n<p>print(EmployeeData)<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p># Creating a new variable in data based on existing variable<\/p>\n<p>EmployeeData[&#8216;AgeSquared&#8217;]= EmployeeData[&#8216;Age&#8217;] **2<\/p>\n<p>&nbsp;<\/p>\n<p># Priting data<\/p>\n<p>print(EmployeeData)<\/p>\n<p>&nbsp;<\/p>\n<p># Creating a new variable in data based on existing variable<\/p>\n<p>EmployeeData[&#8216;AgeLOG&#8217;]= np.log(EmployeeData[&#8216;Age&#8217;])<\/p>\n<p>&nbsp;<\/p>\n<p># Priting data<\/p>\n<p>print(EmployeeData)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Sometimes the logic to be applied for each value of an existing column may be a little complex to fit in one line, so we define a function for that and apply that function to each value of the column. The results are stored as a new column.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Grab the opportunity to learn Python with Entri! Click Here<\/a><\/strong><\/p>\n<p><strong>Why is it important to choose Entri?<\/strong><\/p>\n<ul>\n<li>Excellent online platform for all the Competitive Exams.<\/li>\n<li>Provides updated materials created by the Entri Experts.<\/li>\n<li>Entri provides a best platform with full- length mock tests including previous year question papers.<\/li>\n<li>You can download the app for free and join the required classes.<\/li>\n<li>Entri wishes you all the best for your examinations and future endeavours.<\/li>\n<\/ul>\n<p><strong>\u201cYOU DON\u2019T HAVE TO BE GREAT TO START, BUT YOU HAVE TO START TO BE GREAT.\u201d<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Data Frame is a two-dimension collection of data. It is a data structure where data is stored in tabular form. Datasets are arranged in rows and columns; we can store multiple datasets in the data frame. We can perform various arithmetic operations, such as adding column\/row selection and columns\/rows in the data frame. Learn [&hellip;]<\/p>\n","protected":false},"author":55,"featured_media":25526050,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,558],"tags":[],"class_list":["post-25526048","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-general-knowledge"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Different Ways of Creating DataFrame With Python - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Different Ways of Creating DataFrame With Python - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"A Data Frame is a two-dimension collection of data. It is a data structure where data is stored in tabular form. Datasets are arranged in rows and columns; we can store multiple datasets in the data frame. We can perform various arithmetic operations, such as adding column\/row selection and columns\/rows in the data frame. Learn [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-29T16:53:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-22T11:43:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ayesha Surayya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ayesha Surayya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\"},\"author\":{\"name\":\"Ayesha Surayya\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\"},\"headline\":\"Different Ways of Creating DataFrame With Python\",\"datePublished\":\"2022-05-29T16:53:36+00:00\",\"dateModified\":\"2022-11-22T11:43:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\"},\"wordCount\":1060,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png\",\"articleSection\":[\"Articles\",\"General Knowledge\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\",\"url\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\",\"name\":\"Different Ways of Creating DataFrame With Python - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png\",\"datePublished\":\"2022-05-29T16:53:36+00:00\",\"dateModified\":\"2022-11-22T11:43:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png\",\"width\":820,\"height\":615,\"caption\":\"Different Ways of Creating DataFrame With Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"General Knowledge\",\"item\":\"https:\/\/entri.app\/blog\/category\/general-knowledge\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Different Ways of Creating DataFrame With Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097\",\"name\":\"Ayesha Surayya\",\"url\":\"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Different Ways of Creating DataFrame With Python - Entri Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/","og_locale":"en_US","og_type":"article","og_title":"Different Ways of Creating DataFrame With Python - Entri Blog","og_description":"A Data Frame is a two-dimension collection of data. It is a data structure where data is stored in tabular form. Datasets are arranged in rows and columns; we can store multiple datasets in the data frame. We can perform various arithmetic operations, such as adding column\/row selection and columns\/rows in the data frame. Learn [&hellip;]","og_url":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-05-29T16:53:36+00:00","article_modified_time":"2022-11-22T11:43:58+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png","type":"image\/png"}],"author":"Ayesha Surayya","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Ayesha Surayya","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/"},"author":{"name":"Ayesha Surayya","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097"},"headline":"Different Ways of Creating DataFrame With Python","datePublished":"2022-05-29T16:53:36+00:00","dateModified":"2022-11-22T11:43:58+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/"},"wordCount":1060,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png","articleSection":["Articles","General Knowledge"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/","url":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/","name":"Different Ways of Creating DataFrame With Python - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png","datePublished":"2022-05-29T16:53:36+00:00","dateModified":"2022-11-22T11:43:58+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Different-Ways-of-Creating-DataFrame-With-Python.png","width":820,"height":615,"caption":"Different Ways of Creating DataFrame With Python"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/different-ways-of-creating-dataframe-with-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"General Knowledge","item":"https:\/\/entri.app\/blog\/category\/general-knowledge\/"},{"@type":"ListItem","position":3,"name":"Different Ways of Creating DataFrame With Python"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/568cc9d6e77fd5d01033b61c88343097","name":"Ayesha Surayya","url":"https:\/\/entri.app\/blog\/author\/ayesha-surayya\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25526048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/55"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25526048"}],"version-history":[{"count":4,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25526048\/revisions"}],"predecessor-version":[{"id":25547747,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25526048\/revisions\/25547747"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25526050"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25526048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25526048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25526048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}