{"id":2186,"date":"2019-08-31T06:03:27","date_gmt":"2019-08-31T06:03:27","guid":{"rendered":"https:\/\/machinelearningplus.com\/?p=2186"},"modified":"2022-03-08T17:01:29","modified_gmt":"2022-03-08T17:01:29","slug":"101-python-datatable-exercises-pydatatable","status":"publish","type":"post","link":"https:\/\/machinelearningplus.com\/data-manipulation\/101-python-datatable-exercises-pydatatable\/","title":{"rendered":"101 Python datatable Exercises (pydatatable)"},"content":{"rendered":"<p><em>Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R&#8217;s <code>data.table<\/code> with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data. Looking at the <a href=\"https:\/\/h2oai.github.io\/db-benchmark\/\" target=\"_blank\" rel=\"noopener noreferrer\">performance<\/a> it is on path to become a must-use package for data manipulation in python.<\/em><\/p>\r\n<p><img decoding=\"async\" src=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/python_datatable_poster.jpg\" \/>101 Python datatable Exercises (pydatatable). Photo by Jet Kim.<\/p>\r\n\r\n<h2 id=\"1howtoimportdatatablepackageandchecktheversion\">1. How to import datatable package and check the version?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndt.__version__\r\n<\/code><\/pre>\r\n<pre><code>'0.8.0'\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<p>You need to <code>import datatable as dt<\/code> for the rest of the codes in this exercise to work.<\/p>\r\n<h2 id=\"2howtocreateadatatableframefromalistnumpyarraypandasdataframe\">2. How to create a datatable Frame from a list, numpy array, pandas dataframe?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Create a datatable Frame from a list, numpy array and pandas dataframe.<\/p>\r\n<p>Input:<\/p>\r\n<pre><code class=\"python language-python\">import pandas as pd\r\nimport numpy as np\r\n\r\nmy_list = list('abcedfghijklmnopqrstuvwxyz')\r\nmy_arr = np.arange(26)\r\nmy_df = pd.DataFrame(dict(col1=my_list, col2=my_arr))\r\n<\/code><\/pre>\r\n<p>Desired Output:<\/p>\r\n<p><a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3.png\"><img decoding=\"async\" class=\"aligncenter size-medium wp-image-2200\" src=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3-77x300.png\" alt=\"\" width=\"77\" height=\"300\" srcset=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3-77x300.png 77w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3-264x1024.png 264w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3-100x388.png 100w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_3.png 276w\" sizes=\"(max-width: 77px) 100vw, 77px\" \/><\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import pandas as pd\r\nimport numpy as np\r\nimport datatable as dt\r\n\r\n# Inputs\r\nmy_list = list('abcedfghijklmnopqrstuvwxyz')\r\nmy_arr  = np.arange(26)\r\nmy_df   = pd.DataFrame(dict(col1=my_list, col2=my_arr))\r\n\r\n\r\n# Solution\r\ndt_df1  = dt.Frame(my_list)\r\ndt_df2  = dt.Frame(my_arr)\r\ndt_df3  = dt.Frame(my_df)\r\ndt_df4  = dt.Frame(A=my_arr, B= my_list)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"3howtoimportcsvfileasapydatatableframe\">3. How to import csv file as a pydatatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Read files as datatable Frame.<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-shareaholic-thumbnail wp-image-2194\" src=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-640x147.png\" alt=\"pydatatable 1\" width=\"640\" height=\"147\" srcset=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-640x147.png 640w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-300x69.png 300w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-768x176.png 768w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-1024x235.png 1024w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-100x23.png 100w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-865x198.png 865w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1.png 1184w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\r\n<p><\/div><\/details>\r\n<h2 id=\"4howtoreadfirst5rowsofpydatatableframe\">3. How to read first 5 rows of pydatatable Frame ?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Read first <code>5<\/code> rows of datatable Frame.<\/p>\r\n<p>Input URL for CSV file: https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv', max_nrows= 5)\r\ndf\r\n<\/code><\/pre>\r\n<p><a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-shareaholic-thumbnail wp-image-2194\" src=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-640x147.png\" alt=\"pydatatable 1\" width=\"640\" height=\"147\" srcset=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-640x147.png 640w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-300x69.png 300w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-768x176.png 768w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-1024x235.png 1024w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-100x23.png 100w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1-865x198.png 865w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_1.png 1184w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><br \/><\/div><\/details>\r\n<h2 id=\"5howtoaddnewcolumninpydatatableframefromalist\">4. How to add new column in pydatatable Frame from a list?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Read first <code>5<\/code> rows of datatable Frame and add a new column of length <code>5<\/code>.<\/p>\r\n<p>Input URL for CSV file: https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv', max_nrows= 5)\r\n\r\n# Solution\r\ndf[:,\"new_column\"] = dt.Frame([1,2,3,4,5])\r\ndf\r\n<\/code><\/pre>\r\n<p><a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2.png\"><img decoding=\"async\" class=\"aligncenter size-shareaholic-thumbnail wp-image-2195\" src=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-640x131.png\" alt=\"pydatatable\" width=\"640\" height=\"131\" srcset=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-640x131.png 640w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-300x61.png 300w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-768x157.png 768w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-1024x209.png 1024w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-100x20.png 100w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2-865x177.png 865w, https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/datatable_2.png 1184w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\r\n<p><\/div><\/details>\r\n<h2 id=\"6howtodoadditionofexistingcolumnstogetanewcolumninpydatatableframe\">5. How to do addition of existing columns to get a new column in pydatatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Add <code>age<\/code> and <code>rad<\/code> columns to get a new column in datatable Frame.<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\n\r\n# Solution\r\ndf[:,\"new_column\"] = df[:, dt.f.age + dt.f.rad]\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"7howtogettheintvalueofafloatcolumninapydatatableframe\">6. How to get the int value of a float column in a pydatatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Get the int value of a float column <code>dis<\/code> in datatable Frame.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\n\r\n# Solution\r\ndf[:, \"new_column\"] = df[:, dt.int32(dt.f.dis)]\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/div><\/details><\/p>\r\n<p>&nbsp;<\/p>\r\n<h2 id=\"8howtocreateanewcolumnbasedonaconditioninadatatableframe\">7. How to create a new column based on a condition in a datatable Frame?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Create a new column having value as &#8216;Old&#8217; if age greater than 60 else &#8216;New&#8217; in a `datatable` Frame.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<p><details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/div><\/details><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf[:, \"new_column\"] = dt.Frame(np.where(df[:, dt.f.age &gt; 60], 'Old', 'New'))\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"9howtoleftjointwodatatableframes\">8. How to left join two datatable Frames?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: join two Frames.<\/p>\r\n<p>Input:<\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf1 = dt.Frame(A=[1,2,3,4],B=[\"a\", \"b\", \"c\", \"d\"])\r\ndf2 = dt.Frame(A=[1,2,3,4,5],C=[\"a2\", \"b2\", \"c2\", \"d2\", \"e2\"])\r\n<\/code><\/pre>\r\n<p>Primary Key : A<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf1 = dt.Frame(A=[1,2,3,4],B=[\"a\", \"b\", \"c\", \"d\"])\r\ndf2 = dt.Frame(A=[1,2,3,4,5],C=[\"a2\", \"b2\", \"c2\", \"d2\", \"e2\"])\r\ndf2.key = \"A\"\r\noutput = df1[:, :, dt.join(df2)]\r\noutput\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"10howtorenameacolumninapydatatableframe\">9. How to rename a column in a pydatatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Rename column <code>zn<\/code> to <code>zn_new<\/code> in a datatable Frame.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf.names = {'zn': 'zn_new'}\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"11howtoimportevery50throwfromacsvfiletocreateadatatableframe\">10. How to import every 50th row from a csv file to create a datatable Frame?<\/h2>\r\n<p>Difficiulty Level: L2<\/p>\r\n<p>Question: Import every 50th row of [BostonHousing dataset] (BostonHousing.csv) as a dataframe.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution: Use csv reader. Unfortunately there isn't an option to do it directly using fread()\r\nimport datatable as dt\r\nimport csv          \r\nwith open('local\/path\/to\/BostonHousing.csv', 'r') as f:\r\n    reader = csv.reader(f)\r\n    for i, row in enumerate(reader):\r\n        row = [[x] for x in row]\r\n        # 1st row\r\n        if i == 0:  \r\n            df = dt.Frame(row)\r\n            header = [x[0] for x in df[0,:].to_list()]\r\n            df.names =  header\r\n            del df[0,:]  \r\n        # Every 50th row\r\n        elif i%50 ==0:\r\n            df_temp = dt.Frame(row)\r\n            df_temp.names = header\r\n            df.rbind(df_temp)\r\n\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"12howtochangecolumnvalueswhenimportingcsvtoapythondatatableframe\">11. How to change column values when importing csv to a Python datatable Frame?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Import the <a href=\"BostonHousing.csv\">boston housing dataset<\/a>, but while importing change the <code>'medv'<\/code> (median house value) column so that values &lt; 25 becomes &#8216;Low&#8217; and &gt; 25 becomes &#8216;High&#8217;.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution: Use csv reader\r\nimport datatable as dt\r\nimport csv          \r\nwith open('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv', 'r') as f:\r\n    reader = csv.reader(f)\r\n    for i, row in enumerate(reader):\r\n        row = [[x] for x in row]\r\n        if i == 0:\r\n            df = dt.Frame(row)\r\n            header = [x[0] for x in df[0,:].to_list()]\r\n            df.names =  header\r\n            del df[0,:]  \r\n        else:\r\n            row[13] = ['High'] if float(row[13][0]) &gt; 25 else ['Low']\r\n            df_temp = dt.Frame(row)\r\n            df_temp.names = header\r\n            df.rbind(df_temp)\r\n\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"13howtochangevalueatparticularrowandcolumninapythondatatableframe\">12. How to change value at particular row and column in a Python datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Change value at row number 2 and column number 1 as <code>5<\/code> in a datatable Frame.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution: It follows row, column indexing. No need to use \"loc\", \".loc\"\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf[2,1] = 5\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"14howtodeletespecificcellrowcolumnrowperconditioninadatatableframe\">13. How to delete specific cell, row, column, row per condition in a datatable Frame?<\/h2>\r\n<p>Difficulty Level: 2<\/p>\r\n<p>Questions:<\/p>\r\n<ol>\r\n<li>Delete the cell at position <code>2,1<\/code>.\r\n<p>&nbsp;<\/p>\r\n<\/li>\r\n<li>\r\n<p>Delete the <code>3rd<\/code> row.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Delete the <code>chas<\/code> column.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Delete rows where column <code>zn<\/code> is having 0 value.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution: It follows row,colume indexing. No need to use \"loc\", \".loc\"\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\n\r\n# Delete the cell at position `2,1`.\r\ndel df[2,1]\r\n\r\n# Delete the `3rd` row.\r\ndel df[3,:]\r\n\r\n# Delete the `chas` column.\r\ndel df[:,\"chas\"]\r\n\r\n# Delete rows where column `zn` is having 0 value.\r\ndel df[dt.f.zn == 0,:]\r\n\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"15howtoconvertdatatableframetopandasnumpydictionarylisttuplescsvfiles\">14. How to convert datatable Frame to pandas, numpy, dictionary, list, tuples, csv files?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Convert datatable Frame to pandas, numpy, dictionary, list, tuples, csv files.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\n\r\n# to pandas df\r\npd_df = df.to_pandas()\r\n\r\n# to numpy arrays\r\nnp_arrays = df.to_numpy()\r\n\r\n# to dictionary\r\ndic = df.to_dict()\r\n\r\n# to list\r\nlist_ = df[:,\"indus\"].to_list()\r\n\r\n# to tuple\r\ntuples_ = df[:,\"indus\"].to_tuples()\r\n\r\n# to csv \r\ndf.to_csv(\"BostonHousing.csv\")\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"16howtogetdatatypesofallthecolumnsinthedatatableframe\">15. How to get data types of all the columns in the datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Get data types of all the columns in the datatable Frame.<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code class=\"python language-python\">crim : stype.float64\r\nzn : stype.float64\r\nindus : stype.float64\r\nchas : stype.bool8\r\nnox : stype.float64\r\nrm : stype.float64\r\nage : stype.float64\r\ndis : stype.float64\r\nrad : stype.int32\r\ntax : stype.int32\r\nptratio : stype.float64\r\nb : stype.float64\r\nlstat : stype.float64\r\nmedv : stype.float64\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\nfor i in range(len(df.names)):\r\n    print(df.names[i], \":\", df.stypes[i])\r\n<\/code><\/pre>\r\n<pre><code>crim : stype.float64\r\nzn : stype.float64\r\nindus : stype.float64\r\nchas : stype.bool8\r\nnox : stype.float64\r\nrm : stype.float64\r\nage : stype.float64\r\ndis : stype.float64\r\nrad : stype.int32\r\ntax : stype.int32\r\nptratio : stype.float64\r\nb : stype.float64\r\nlstat : stype.float64\r\nmedv : stype.float64\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"17howtogetsummarystatsofeachcolumnindatatableframe\">16. How to get summary stats of each column in datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Questions:<\/p>\r\n<p>For each column:<\/p>\r\n<ol>\r\n<li>Get the sum of the column values.\r\n<p>&nbsp;<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the max of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the min of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the mean of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the standard deviation of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the mode of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the modal value of the column values.<\/p>\r\n<\/li>\r\n<li>\r\n<p>Get the number of unique values in column.<\/p>\r\n<\/li>\r\n<\/ol>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf.sum()\r\ndf.max()\r\ndf.min()\r\ndf.mean()\r\ndf.sd()\r\ndf.mode()\r\ndf.nmodal()\r\ndf.nunique()\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"18howtogetthecolumnstatsofparticularcolumnofthedatatableframe\">17. How to get the column stats of particular column of the datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Get the max value of <code>zn<\/code> column of the datatable Frame<\/p>\r\n<p>Input: <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<p>Desired Output: 100<\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv')\r\ndf[:,dt.max(dt.f.zn)]\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"19howtoapplygroupbyfunctionsindatatableframe\">18. How to apply group by functions in datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Find the mean price for every manufacturer using <a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a> dataset.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code>     Manufacturer         C0\r\n0            None  28.550000\r\n1           Acura  15.900000\r\n2            Audi  33.400000\r\n3             BMW  30.000000\r\n4           Buick  21.625000\r\n5        Cadillac  37.400000\r\n..\r\n..\r\n\r\n30     Volkswagen  18.025000\r\n31          Volvo  22.700000\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\ndf[:, dt.mean(dt.f.Price), dt.by(\"Manufacturer\")].head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"20howtoarrangedatatabeframeinascendingorderbycolumnvalue\">19. How to arrange datatabe Frame in ascending order by column value?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Arrange datatable Frame in ascending order by <code>Price<\/code>.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code>Manufacturer    Model     Type  Min.Price  Price  Max.Price  MPG.city  \\ \r\n0       Saturn       SL    Small        9.2    NaN       12.9       NaN   \r\n1       Toyota    Camry  Midsize       15.2    NaN       21.2      22.0   \r\n2         Ford  Festiva    Small        6.9    7.4        7.9      31.0   \r\n3      Hyundai    Excel    Small        6.8    8.0        9.2      29.0   \r\n4        Mazda      323    Small        7.4    8.3        9.1      29.0   \r\n\r\n\r\n   Width  Turn.circle Rear.seat.room  Luggage.room  Weight   Origin  \\\r\n0   68.0         40.0           26.5           NaN  2495.0      USA   \r\n1   70.0         38.0           28.5          15.0  3030.0  non-USA   \r\n2   63.0         33.0           26.0          12.0  1845.0      USA   \r\n3   63.0         35.0           26.0          11.0  2345.0  non-USA   \r\n4   66.0         34.0           27.0          16.0  2325.0  non-USA   \r\n\r\n            Make  \r\n0      Saturn SL  \r\n1   Toyota Camry  \r\n2   Ford Festiva  \r\n3  Hyundai Excel  \r\n4      Mazda 323  \r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution1\r\ndf.sort(\"Price\")\r\n\r\n# Solution2\r\ndf[:,:, dt.sort(dt.f.Price)].head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"21howtoarrangedatatabeframeindescendingorderbycolumnvalue\">20. How to arrange datatabe Frame in descending order by column value?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Arrange datatable Frame in descending order by <code>Price<\/code>.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code>   Manufacturer     Model     Type  Min.Price  Price  Max.Price  MPG.city  \\\r\n0  Mercedes-Benz      300E  Midsize       43.8   61.9       80.0      19.0   \r\n1       Infiniti       Q45  Midsize       45.4   47.9        NaN      17.0   \r\n2       Cadillac   Seville  Midsize       37.5   40.1       42.7      16.0   \r\n3      Chevrolet  Corvette   Sporty       34.6   38.0       41.5      17.0   \r\n4           Audi       100  Midsize        NaN   37.7       44.6      19.0   \r\n\r\n   MPG.highway             AirBags DriveTrain  ... Passengers  Length  \\\r\n0         25.0  Driver &amp; Passenger       Rear  ...        5.0     NaN   \r\n1         22.0                None       Rear  ...        5.0   200.0   \r\n2         25.0  Driver &amp; Passenger      Front  ...        5.0   204.0   \r\n3         25.0         Driver only       Rear  ...        2.0   179.0   \r\n4         26.0  Driver &amp; Passenger       None  ...        6.0   193.0   \r\n\r\n   Wheelbase  Width  Turn.circle Rear.seat.room  Luggage.room  Weight  \\\r\n0      110.0   69.0         37.0            NaN          15.0  3525.0   \r\n1      113.0   72.0         42.0           29.0          15.0  4000.0   \r\n2      111.0   74.0         44.0           31.0           NaN  3935.0   \r\n3       96.0   74.0         43.0            NaN           NaN  3380.0   \r\n4      106.0    NaN         37.0           31.0          17.0  3405.0   \r\n\r\n    Origin                Make  \r\n0  non-USA  Mercedes-Benz 300E  \r\n1  non-USA        Infiniti Q45  \r\n2      USA    Cadillac Seville  \r\n3     None  Chevrolet Corvette  \r\n4  non-USA            Audi 100  \r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf[::-1,:, dt.sort(dt.f.Price)].head()\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"22howtorepeatappendthesamedataindatatableframe\">21. How to repeat(append) the same data in datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Repeat(append) the same data 5 times in datatable Frame.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndt.repeat(df, 5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"23howtoreplacestringwithanotherstringinentiredatatableframe\">22. How to replace string with another string in entire datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Replace <code>Audi<\/code> with <code>My Dream Car<\/code> in entire datatable Frame.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf.replace(\"Audi\", \"My Dream Car\")\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"24howtoextractthedetailsofaparticularcellwithgivencriterion\">23. How to extract the details of a particular cell with given criterion??<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Extract which manufacturer, model and type has the highest <code>Price<\/code>.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code> Manufacturer  Model     Type\r\n Mercedes-Benz  300E  Midsize\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\n\r\n# Get the highest price\r\nprint(\"Highest Price : \", df[:,dt.f.Price].max()[0,0])\r\n\r\n# Get Manufacturer with highest price\r\ndf[dt.f.Price ==  df[:,dt.f.Price].max()[0,0], ['Manufacturer', 'Model', 'Type']]\r\n<\/code><\/pre>\r\n<pre><code>Highest Price :  61.9\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"25howtorenameaspecificcolumnsinadataframe\">24. How to rename a specific columns in a dataframe?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Rename the column <code>Model<\/code> as <code>Car Model<\/code>.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\nold_col_name = \"Model\"\r\nnew_col_name = \"Car Model\"\r\ndf.names = [new_col_name if x == old_col_name else x for x in df.names]\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"26howtocountnavaluesineverycolumnofadatatableframe\">25. How to count NA values in every column of a datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: Count NA values in every column of a datatable Frame.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code>Manufacturer  Model  Type  Min.Price  Price  Max.Price  MPG.city  \\\r\n0             4      1     3          7      2          5         9   \r\n\r\n   MPG.highway  AirBags  DriveTrain  ...  Passengers  Length  Wheelbase  \\\r\n0            2        6           7  ...           2       4          1   \r\n\r\n   Width  Turn.circle  Rear.seat.room  Luggage.room  Weight  Origin  Make  \r\n0      6            5               4            19       7       5     3\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf.countna()\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"27howtogetaspecificcolumnfromadatatableframeasadatatableframeinsteadofaseries\">26. How to get a specific column from a datatable Frame as a datatable Frame instead of a series?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question :Get the column (<code>Model<\/code>) in datatable Frame as a datatable Frame (rather than as a Series).<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf[:,\"Model\"].head(5)\r\n<\/code><\/pre>\r\n<div class=\"datatable\">\r\n<table class=\"frame\">\r\n<thead>\r\n<tr class=\"colnames\">\r\n<td class=\"row_index\">\u00a0<\/td>\r\n<th>Model<\/th>\r\n<\/tr>\r\n<tr class=\"coltypes\">\r\n<td class=\"row_index\">\u00a0<\/td>\r\n<td class=\"str\" title=\"str32\">\u25aa\u25aa\u25aa\u25aa<\/td>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td class=\"row_index\">0<\/td>\r\n<td>Integra<\/td>\r\n<\/tr>\r\n<tr>\r\n<td class=\"row_index\">1<\/td>\r\n<td>Legend<\/td>\r\n<\/tr>\r\n<tr>\r\n<td class=\"row_index\">2<\/td>\r\n<td>90<\/td>\r\n<\/tr>\r\n<tr>\r\n<td class=\"row_index\">3<\/td>\r\n<td>100<\/td>\r\n<\/tr>\r\n<tr>\r\n<td class=\"row_index\">4<\/td>\r\n<td>535i<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<div class=\"footer\">\r\n<div class=\"frame_dimensions\">5 rows \u00d7 1 column<\/div>\r\n<p>&nbsp;<\/p>\r\n<\/div>\r\n<p><\/div><\/details>\r\n<h2 id=\"28howtoreversetheorderofcolumnsofadatatableframe\">27. How to reverse the order of columns of a datatable Frame?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question : Reverse the order of columns in <code>Cars93<\/code> datatable Frame.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution 1\r\ndf.head()\r\ndf[:,::-1].head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"29howtoformatorsuppressscientificnotationsinpythondatatableframe\">28. How to format or suppress scientific notations in Python datatable Frame?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Suppress scientific notations like &#8216;e-03&#8217; in <code>df<\/code> and print upto 6 numbers after decimal.<\/p>\r\n<p>Input<\/p>\r\n<pre><code class=\"python  language-python \">import datatable as dt\r\ndf = dt.Frame(random=np.random.random(4)**10)\r\ndf\r\n         random\r\n0  3.518290e-04\r\n1  5.104371e-02\r\n2  5.895886e-06\r\n3  1.274671e-09\r\n<\/code><\/pre>\r\n<p>Desired Output<\/p>\r\n<pre><code class=\"python language-python\">         random   random2\r\n0  3.518290e-04  0.000352\r\n1  5.104371e-02  0.051044\r\n2  5.895886e-06  0.000006\r\n3  1.274671e-09  0.000000\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Solution\r\nimport datatable as dt\r\ndf = dt.Frame(random=np.random.random(4)**10)\r\ndf[:,\"random2\"] = dt.Frame(['%.6f' % x for x in df[:,\"random\"].to_list()[0]])\r\ndf\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"30howtofiltereverynthrowinapydatatable\">29. How to filter every nth row in a pydatatable?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: From <code>df<\/code>, filter the <code>'Manufacturer'<\/code>, <code>'Model'<\/code> and <code>'Type'<\/code> for every 20th row starting from 1st (row 0).<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf[::20, ['Manufacturer', 'Model', 'Type']]\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"31howtoreversetherowsofapythondatatableframe\">30. How to reverse the rows of a python datatable Frame?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Reverse all the rows.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv\">Cars93<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread('https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/Cars93_miss.csv')\r\n\r\n# Solution\r\ndf[::-1,:]\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"32howtofindoutwhichcolumncontainsthehighestnumberofrowwisemaximumvalues\">31. How to find out which column contains the highest number of row-wise maximum values?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: What is the column name with the highest number of row-wise maximum&#8217;s.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<p>Desired Output:<br \/><code>tax<\/code><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread(\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\")\r\n\r\n# Solution\r\nfor i in range(len(df.names)):\r\n    if df.sum()[0:1,:].to_list()[i] == max(df.sum()[0:1,:].to_list()):\r\n        print(df.names[i])\r\n<\/code><\/pre>\r\n<pre><code>tax\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"33howtonormalizeallcolumnsinadataframe\">32. How to normalize all columns in a dataframe?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Questions:<\/p>\r\n<ol>\r\n<li>Normalize all columns of <code>df<\/code> by subtracting the column mean and divide by standard deviation.<\/li>\r\n<li>Range all columns of <code>df<\/code> such that the minimum value in each column is 0 and max is 1.<\/li>\r\n<\/ol>\r\n<p>Don&#8217;t use external packages like sklearn.<\/p>\r\n<p>Input:<br \/><a href=\"https:\/\/raw.githubusercontent.com\/selva86\/datasets\/master\/BostonHousing.csv\">BostonHousing dataset<\/a><\/p>\r\n<p>Desired Output:<\/p>\r\n<pre><code>       crim    zn     indus  chas       nox        rm       age       dis  \\\r\n0  0.000000  0.18  0.067815   0.0  0.314815  0.577505  0.641607  0.269203   \r\n1  0.000236  0.00  0.242302   0.0  0.172840  0.547998  0.782698  0.348962   \r\n2  0.000236  0.00  0.242302   0.0  0.172840  0.694386  0.599382  0.348962   \r\n3  0.000293  0.00  0.063050   0.0  0.150206  0.658555  0.441813  0.448545   \r\n4  0.000705  0.00  0.063050   0.0  0.150206  0.687105  0.528321  0.448545   \r\n\r\n        rad       tax   ptratio         b     lstat      medv  \r\n0  0.000000  0.208015  0.287234  1.000000  0.089680  0.422222  \r\n1  0.043478  0.104962  0.553191  1.000000  0.204470  0.368889  \r\n2  0.043478  0.104962  0.553191  0.989737  0.063466  0.660000  \r\n3  0.086957  0.066794  0.648936  0.994276  0.033389  0.631111  \r\n4  0.086957  0.066794  0.648936  1.000000  0.099338  0.693333\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.fread(\"BostonHousing.csv\")\r\n\r\n# Solution\r\nfor i in df.names:\r\n    df[:,i] = df[:,(dt.f[i] - df[:,dt.min(dt.f[i])][0,0])\/(df[:,dt.max(dt.f[i])][0,0] - df[:,dt.min(dt.f[i])][0,0])]\r\ndf.head(5)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"34howtocomputegroupedmeanondatatableframeandkeepthegroupedcolumnasanothercolumn\">33. How to compute grouped mean on datatable Frame and keep the grouped column as another column?<\/h2>\r\n<p>Difficulty Level: L1<\/p>\r\n<p>Question: In <code>df<\/code>, Compute the mean <code>price<\/code> of every <code>fruit<\/code>, while keeping the <code>fruit<\/code> as another column instead of an index.<\/p>\r\n<p>Input<\/p>\r\n<pre><code class=\"python language-python\">df = dt.Frame(fruit = ['apple', 'banana', 'orange'] * 3,\r\n             rating =  np.random.rand(9),\r\n             price  =  np.random.randint(0, 15, 9))\r\n<\/code><\/pre>\r\n<p>Desired Output:<\/p>\r\n<pre><code>    fruit        C0\r\n0   apple  7.666667\r\n1  banana  5.000000\r\n2  orange  8.333333\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.Frame(fruit = ['apple', 'banana', 'orange'] * 3,\r\n             rating =  np.random.rand(9),\r\n             price  =  np.random.randint(0, 15, 9))\r\ndf[:, dt.mean(dt.f.price), dt.by(\"fruit\")]\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"35howtojointwodatatableframesby2columns\">34. How to join two datatable Frames by 2 columns?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Join dataframes <code>df1<\/code> and <code>df2<\/code> by &#8216;A&#8217; and &#8216;B&#8217;.<\/p>\r\n<p>Input<\/p>\r\n<pre><code class=\"python language-python\">df1 = dt.Frame(A=[1, 2, 3, 4],\r\n               B=[\"a\", \"b\", \"c\", \"d\"],\r\n               D=[1, 2, 3, 4])\r\n\r\ndf2 = dt.Frame(A=[1, 2, 4, 5],\r\n               B=[\"a\", \"b\", \"d\", \"e\"],\r\n               C=[\"a2\", \"b2\", \"d2\", \"e2\"])\r\n<\/code><\/pre>\r\n<p>Desired Output:<\/p>\r\n<pre><code>   A  B  D   C\r\n0  1  a  1  a2\r\n1  2  b  2  b2\r\n2  3  c  3  \r\n3  4  d  4  d2\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf1 = dt.Frame(A=[1, 2, 3, 4], B=[\"a\", \"b\", \"c\", \"d\"], D=[1, 2, 3, 4])\r\ndf2 = dt.Frame(A=[1, 2, 4, 5], B=[\"a\", \"b\", \"d\", \"e\"], C=[\"a2\", \"b2\", \"d2\", \"e2\"])\r\n\r\n# Solution\r\ndf2.key = [\"A\",\"B\"]\r\noutput = df1[:, :, dt.join(df2)]\r\noutput\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2 id=\"36howtocreateleadscolumnshiftedupby1rowofacolumninadatatableframe\">35. How to create leads (column shifted up by 1 row) of a column in a datatable Frame?<\/h2>\r\n<p>Difficulty Level: L2<\/p>\r\n<p>Question: Create new column in <code>df<\/code>, which is a lead1 (shift column <code>A<\/code> up by 1 row).<\/p>\r\n<p>Input:<\/p>\r\n<pre><code class=\"python language-python\">df = dt.Frame(A=[1,2,3,4],B=[\"a\", \"b\", \"c\", \"d\"],d=[1,2,3,4])\r\n<\/code><\/pre>\r\n<p>Desired Output:<\/p>\r\n<pre><code class=\"python language-python\">   A  B  d  A.1\r\n0  1  a  1    2\r\n1  2  b  2    3\r\n2  3  c  3    4\r\n3  4  d  4  NaN\r\n<\/code><\/pre>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\"># Input\r\nimport datatable as dt\r\ndf = dt.Frame(A=[1,2,3,4],B=[\"a\", \"b\", \"c\", \"d\"],d=[1,2,3,4])\r\n\r\n# Solution\r\ndt.cbind(df1,df[1:,\"A\"],force= True)\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<h2>36. Machine Learning Exercise &#8211; How to use FTRL Model to calculate the probability of a person having diabetes?<\/h2>\r\n<h3 id=\"36howtouseftrlmodeltocalculatetheprobablityofapersonhavingdiabetes\">\u00a0<\/h3>\r\n<p>Difficulty Level: L3<\/p>\r\n<p><strong>Question 1:<\/strong> Use Follow the Regularized Leader (<code>Ftrl<\/code>) Model to calculate the probability of a person having diabetes.<\/p>\r\n<p><strong>Question 2:<\/strong> Find the feature importance of the features used in model.<\/p>\r\n<p><strong>Input:<\/strong><\/p>\r\n<p>Training Data : <a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pima_indian_diabetes_training_data.csv\" target=\"_blank\" rel=\"noopener noreferrer\">pima_indian_diabetes_training_data.csv<\/a><\/p>\r\n<p>Testing Data : <a href=\"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pima_indian_diabetes_testing_data.csv\" target=\"_blank\" rel=\"noopener noreferrer\">pima_indian_diabetes_testing_data.csv<\/a><\/p>\r\n<details class=\"blogv4-expand\"><summary class=\"blogv4-expand__toggle\">Show Solution<\/summary><div class=\"blogv4-expand__body\"><\/p>\r\n<pre><code class=\"python language-python\">import datatable as dt\r\nfrom datatable.models import Ftrl\r\n\r\n# Import data\r\ntrain_df = dt.fread('pima_indian_diabetes_training_data.csv')\r\ntest_df = dt.fread('pima_indian_diabetes_testing_data.csv')\r\n\r\n# Create Ftrl model\r\nftrl_model = Ftrl()\r\n\r\n#  add parameter values while creating model\r\nftrl_model = Ftrl(alpha = 0.1, lambda1 = 0.5, lambda2 = 0.6)\r\n\r\n# change paramter of existing model\r\nftrl_model.alpha = 0.1\r\nftrl_model.lambda1 = 0.5\r\nftrl_model.lambda2 = 0.6\r\n\r\n# Prepare training and test dataset\r\ntrain_df[:,\"diabetes\"] = dt.Frame(np.where(train_df[:, dt.f[\"diabetes\"] == \"pos\"], 1,0))\r\ntest_df[:,\"diabetes\"] = dt.Frame(np.where(test_df[:, dt.f[\"diabetes\"] == \"pos\"], 1,0))\r\n\r\nx_train = train_df[:, [\"pregnant\", \"glucose\", \"pressure\", \"mass\", \"pedigree\", \"age\"]]\r\ny_train = train_df[:, [\"diabetes\"]]\r\n\r\nx_test = test_df[:, [\"pregnant\", \"glucose\", \"pressure\", \"mass\", \"pedigree\", \"age\"]]\r\ny_test = test_df[:, [\"diabetes\"]]\r\n\r\n# training the model\r\nftrl_model.fit(x_train,y_train)\r\n\r\n# predictions of the model\r\ntargets = ftrl_model.predict(x_test)\r\nprint(targets.head(5))\r\n\r\n# feature importance\r\nfi = ftrl_model.feature_importances\r\nfi\r\n<\/code><\/pre>\r\n<p><\/div><\/details>\r\n<\/div>\r\n\r\n<p class=\"wp-block-paragraph\">To be continued&#8230;<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R&#8217;s data.table with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data. Looking at the performance it is on path to become a must-use package for data [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2206,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[27,1878,87,22],"class_list":["post-2186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-manipulation","tag-data-manipulation","tag-exercises","tag-pydatatable","tag-python"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>101 Python datatable Exercises (pydatatable) - machinelearningplus<\/title>\n<meta name=\"description\" content=\"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R&#039;s `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"101 Python datatable Exercises (pydatatable) - machinelearningplus\" \/>\n<meta property=\"og:description\" content=\"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R&#039;s `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/\" \/>\n<meta property=\"og:site_name\" content=\"machinelearningplus\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rtipaday\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-31T06:03:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-08T17:01:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/localhost:8080\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png\" \/>\n\t<meta property=\"og:image:width\" content=\"560\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Selva Prabhakaran\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/R_Programming\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Selva Prabhakaran\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/\"},\"author\":{\"name\":\"Selva Prabhakaran\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#\\\/schema\\\/person\\\/510885c0515804366fa644c38258391e\"},\"headline\":\"101 Python datatable Exercises (pydatatable)\",\"datePublished\":\"2019-08-31T06:03:27+00:00\",\"dateModified\":\"2022-03-08T17:01:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/\"},\"wordCount\":1493,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/pydatatable_feature.png\",\"keywords\":[\"Data Manipulation\",\"Exercises\",\"pydatatable\",\"Python\"],\"articleSection\":[\"Data Manipulation\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/\",\"url\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/\",\"name\":\"101 Python datatable Exercises (pydatatable) - machinelearningplus\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/pydatatable_feature.png\",\"datePublished\":\"2019-08-31T06:03:27+00:00\",\"dateModified\":\"2022-03-08T17:01:29+00:00\",\"description\":\"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R's `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/localhost:8080\\\/data-manipulation\\\/101-python-datatable-exercises-pydatatable\\\/#primaryimage\",\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/pydatatable_feature.png\",\"contentUrl\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/pydatatable_feature.png\",\"width\":560,\"height\":315,\"caption\":\"datatable in Python\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#website\",\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/\",\"name\":\"machinelearningplus\",\"description\":\"Learn Data Science (AI \\\/ ML) Online\",\"publisher\":{\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/machinelearningplus.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#organization\",\"name\":\"machinelearningplus\",\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/MachineLearningplus-logo.svg\",\"contentUrl\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/MachineLearningplus-logo.svg\",\"width\":348,\"height\":36,\"caption\":\"machinelearningplus\"},\"image\":{\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/#\\\/schema\\\/person\\\/510885c0515804366fa644c38258391e\",\"name\":\"Selva Prabhakaran\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/litespeed\\\/avatar\\\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267\",\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/litespeed\\\/avatar\\\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267\",\"contentUrl\":\"https:\\\/\\\/machinelearningplus.com\\\/wp-content\\\/litespeed\\\/avatar\\\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267\",\"caption\":\"Selva Prabhakaran\"},\"description\":\"Selva is an experienced Data Scientist and leader, specializing in executing AI projects for large companies. Selva started machinelearningplus to make Data Science \\\/ ML \\\/ AI accessible to everyone. The website enjoys 4 Million+ readership. His courses, lessons, and videos are loved by hundreds of thousands of students and practitioners.\",\"sameAs\":[\"https:\\\/\\\/localhost:8080\\\/\",\"https:\\\/\\\/www.facebook.com\\\/rtipaday\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/R_Programming\"],\"url\":\"https:\\\/\\\/machinelearningplus.com\\\/author\\\/selva86\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"101 Python datatable Exercises (pydatatable) - machinelearningplus","description":"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R's `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.","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:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/","og_locale":"en_US","og_type":"article","og_title":"101 Python datatable Exercises (pydatatable) - machinelearningplus","og_description":"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R's `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.","og_url":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/","og_site_name":"machinelearningplus","article_author":"https:\/\/www.facebook.com\/rtipaday\/","article_published_time":"2019-08-31T06:03:27+00:00","article_modified_time":"2022-03-08T17:01:29+00:00","og_image":[{"width":560,"height":315,"url":"https:\/\/localhost:8080\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png","type":"image\/png"}],"author":"Selva Prabhakaran","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/R_Programming","twitter_misc":{"Written by":"Selva Prabhakaran","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#article","isPartOf":{"@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/"},"author":{"name":"Selva Prabhakaran","@id":"https:\/\/machinelearningplus.com\/#\/schema\/person\/510885c0515804366fa644c38258391e"},"headline":"101 Python datatable Exercises (pydatatable)","datePublished":"2019-08-31T06:03:27+00:00","dateModified":"2022-03-08T17:01:29+00:00","mainEntityOfPage":{"@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/"},"wordCount":1493,"commentCount":6,"publisher":{"@id":"https:\/\/machinelearningplus.com\/#organization"},"image":{"@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#primaryimage"},"thumbnailUrl":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png","keywords":["Data Manipulation","Exercises","pydatatable","Python"],"articleSection":["Data Manipulation"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/","url":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/","name":"101 Python datatable Exercises (pydatatable) - machinelearningplus","isPartOf":{"@id":"https:\/\/machinelearningplus.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#primaryimage"},"image":{"@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#primaryimage"},"thumbnailUrl":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png","datePublished":"2019-08-31T06:03:27+00:00","dateModified":"2022-03-08T17:01:29+00:00","description":"Python datatable is the newest package for data manipulation and analysis in Python. It carries the spirit of R's `data.table` with similar syntax. It is super fast, much faster than pandas and has the ability to work with out-of-memory data.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/localhost:8080\/data-manipulation\/101-python-datatable-exercises-pydatatable\/#primaryimage","url":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png","contentUrl":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2019\/08\/pydatatable_feature.png","width":560,"height":315,"caption":"datatable in Python"},{"@type":"WebSite","@id":"https:\/\/machinelearningplus.com\/#website","url":"https:\/\/machinelearningplus.com\/","name":"machinelearningplus","description":"Learn Data Science (AI \/ ML) Online","publisher":{"@id":"https:\/\/machinelearningplus.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/machinelearningplus.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/machinelearningplus.com\/#organization","name":"machinelearningplus","url":"https:\/\/machinelearningplus.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/machinelearningplus.com\/#\/schema\/logo\/image\/","url":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2022\/05\/MachineLearningplus-logo.svg","contentUrl":"https:\/\/machinelearningplus.com\/wp-content\/uploads\/2022\/05\/MachineLearningplus-logo.svg","width":348,"height":36,"caption":"machinelearningplus"},"image":{"@id":"https:\/\/machinelearningplus.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/machinelearningplus.com\/#\/schema\/person\/510885c0515804366fa644c38258391e","name":"Selva Prabhakaran","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/machinelearningplus.com\/wp-content\/litespeed\/avatar\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267","url":"https:\/\/machinelearningplus.com\/wp-content\/litespeed\/avatar\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267","contentUrl":"https:\/\/machinelearningplus.com\/wp-content\/litespeed\/avatar\/a994280177da541405c016f593e86ea7.jpg?ver=1783622267","caption":"Selva Prabhakaran"},"description":"Selva is an experienced Data Scientist and leader, specializing in executing AI projects for large companies. Selva started machinelearningplus to make Data Science \/ ML \/ AI accessible to everyone. The website enjoys 4 Million+ readership. His courses, lessons, and videos are loved by hundreds of thousands of students and practitioners.","sameAs":["https:\/\/localhost:8080\/","https:\/\/www.facebook.com\/rtipaday\/","https:\/\/x.com\/https:\/\/twitter.com\/R_Programming"],"url":"https:\/\/machinelearningplus.com\/author\/selva86\/"}]}},"_links":{"self":[{"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/posts\/2186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/comments?post=2186"}],"version-history":[{"count":0,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/posts\/2186\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/media\/2206"}],"wp:attachment":[{"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/media?parent=2186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/categories?post=2186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/machinelearningplus.com\/wp-json\/wp\/v2\/tags?post=2186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}