diff --git a/Copy_of_Numpy_Exercises.ipynb b/Copy_of_Numpy_Exercises.ipynb
new file mode 100644
index 0000000..d5ac3ec
--- /dev/null
+++ b/Copy_of_Numpy_Exercises.ipynb
@@ -0,0 +1,371 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "Copy of Numpy_Exercises.ipynb",
+ "version": "0.3.2",
+ "provenance": [],
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "[View in Colaboratory](https://colab.research.google.com/github/dnc2k/Assignment-2/blob/dnc2k/Copy_of_Numpy_Exercises.ipynb)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "a_4UupTr9fbX",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "# Numpy Exercises\n",
+ "\n",
+ "1) Create a uniform subdivision of the interval -1.3 to 2.5 with 64 subdivisions"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "LIP5u4zi0Nmg",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 311
+ },
+ "outputId": "23b1a117-1e5b-4256-d322-3b95cec3d1c5"
+ },
+ "cell_type": "code",
+ "source": [
+ "import numpy as np #import numpy\n",
+ "a=np.linspace(-1.3,2.5,64).reshape(8,8)\n",
+ "print (a)"
+ ],
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[[-1.3 -1.23968254 -1.17936508 -1.11904762 -1.05873016 -0.9984127\n",
+ " -0.93809524 -0.87777778]\n",
+ " [-0.81746032 -0.75714286 -0.6968254 -0.63650794 -0.57619048 -0.51587302\n",
+ " -0.45555556 -0.3952381 ]\n",
+ " [-0.33492063 -0.27460317 -0.21428571 -0.15396825 -0.09365079 -0.03333333\n",
+ " 0.02698413 0.08730159]\n",
+ " [ 0.14761905 0.20793651 0.26825397 0.32857143 0.38888889 0.44920635\n",
+ " 0.50952381 0.56984127]\n",
+ " [ 0.63015873 0.69047619 0.75079365 0.81111111 0.87142857 0.93174603\n",
+ " 0.99206349 1.05238095]\n",
+ " [ 1.11269841 1.17301587 1.23333333 1.29365079 1.35396825 1.41428571\n",
+ " 1.47460317 1.53492063]\n",
+ " [ 1.5952381 1.65555556 1.71587302 1.77619048 1.83650794 1.8968254\n",
+ " 1.95714286 2.01746032]\n",
+ " [ 2.07777778 2.13809524 2.1984127 2.25873016 2.31904762 2.37936508\n",
+ " 2.43968254 2.5 ]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "dBoH_A7M9jjL",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "2) Generate an array of length 3n filled with the cyclic pattern 1, 2, 3"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "4TxT66309n1o",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "13ce8763-8b0e-4de1-ad88-7f870e808022"
+ },
+ "cell_type": "code",
+ "source": [
+ "a1=np.array([1,2,3])\n",
+ "a2=np.resize(a1,3)\n",
+ "print (a2)"
+ ],
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[1 2 3]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "Vh-UKizx9oTp",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "3) Create an array of the first 10 odd integers."
+ ]
+ },
+ {
+ "metadata": {
+ "id": "ebhEUZq29r32",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "0efbd9b4-7bc8-4978-e6f6-0fe847326a45"
+ },
+ "cell_type": "code",
+ "source": [
+ "a2=np.arange(1,20,2)\n",
+ "print (a2)"
+ ],
+ "execution_count": 0,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[ 1 3 5 7 9 11 13 15 17 19]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "QfJRdMat90f4",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "4) Find intersection of a and b"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "gOlfuJCo-JwF",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "766a60e1-d170-41e5-8526-8e13d55546a3"
+ },
+ "cell_type": "code",
+ "source": [
+ "#expected output array([2, 4])\n",
+ "a = np.array([1,2,3,2,3,4,3,4,5,6])\n",
+ "b = np.array([7,2,10,2,7,4,9,4,9,8])\n",
+ "I = np.intersect1d(a,b)\n",
+ "print ('I',I)\n"
+ ],
+ "execution_count": 0,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "I [2 4]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "RtVCf0UoCeB8",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "5) Reshape 1d array a to 2d array of 2X5"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "2E8b55_2Cjx5",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 72
+ },
+ "outputId": "0321e16b-580e-4f68-e128-ef07b70086f1"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.arange(10)\n",
+ "a1= a.reshape(2,5)\n",
+ "print ('After reshape \\n',a1)"
+ ],
+ "execution_count": 0,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "After reshape \n",
+ " [[0 1 2 3 4]\n",
+ " [5 6 7 8 9]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "dVrSBW1zEjp2",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "6) Create a numpy array to list and vice versa"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "tcBCyhXPEp9C",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 90
+ },
+ "outputId": "b11709dd-14c1-441f-ea05-42815cc546d8"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
+ "a1=np.array(a)\n",
+ "print (\"1-D array:\\n\" , a1)\n",
+ "l1=a1.tolist()\n",
+ "print (\"Array to List:\\n\", l1)"
+ ],
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "1-D array:\n",
+ " [1 2 3 4 5 6 7 8 9]\n",
+ "Array to List:\n",
+ " [1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "JNqX8wnz9sQJ",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "7) Create a 10 x 10 arrays of zeros and then \"frame\" it with a border of ones."
+ ]
+ },
+ {
+ "metadata": {
+ "id": "4bjP3JAc9vRD",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 201
+ },
+ "outputId": "2618d44e-9f7a-423c-f4f4-ba5b2cc4b2b9"
+ },
+ "cell_type": "code",
+ "source": [
+ "a=np.zeros(shape=(10,10),dtype=int)\n",
+ "a[0,:]=1\n",
+ "a[:,0]=1\n",
+ "a[9,:]=1\n",
+ "a[:,9]=1\n",
+ "print (a)"
+ ],
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[[1 1 1 1 1 1 1 1 1 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 0 0 0 0 0 0 0 0 1]\n",
+ " [1 1 1 1 1 1 1 1 1 1]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "xaQgf8tT9v-n",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "8) Create an 8 x 8 array with a checkerboard pattern of zeros and ones using a slicing+striding approach."
+ ]
+ },
+ {
+ "metadata": {
+ "id": "No7fx0Xy9zEh",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 182
+ },
+ "outputId": "0e8bcd3c-2881-467b-ffdb-6c57153a46c0"
+ },
+ "cell_type": "code",
+ "source": [
+ "import numpy as np\n",
+ "x=np.zeros(shape=(8,8),dtype=int)\n",
+ "x[1::2,::2]=1\n",
+ "x[::2,1::2]=1\n",
+ "print (\"Checkerboard Pattern:\\n\",x)"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Checkerboard Pattern:\n",
+ " [[0 1 0 1 0 1 0 1]\n",
+ " [1 0 1 0 1 0 1 0]\n",
+ " [0 1 0 1 0 1 0 1]\n",
+ " [1 0 1 0 1 0 1 0]\n",
+ " [0 1 0 1 0 1 0 1]\n",
+ " [1 0 1 0 1 0 1 0]\n",
+ " [0 1 0 1 0 1 0 1]\n",
+ " [1 0 1 0 1 0 1 0]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Copy_of_dnc2k.ipynb b/Copy_of_dnc2k.ipynb
new file mode 100644
index 0000000..c048631
--- /dev/null
+++ b/Copy_of_dnc2k.ipynb
@@ -0,0 +1,93 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "Copy of dnc2k.ipynb",
+ "version": "0.3.2",
+ "provenance": [],
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "[View in Colaboratory](https://colab.research.google.com/github/dnc2k/Assignment-2/blob/dnc2k/Copy_of_dnc2k.ipynb)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "lqNVh-T-sXGj",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 201
+ },
+ "outputId": "2830c962-2b72-4da3-8646-cad7e83ab7b8"
+ },
+ "cell_type": "code",
+ "source": [
+ "dummy_list=[23,82,98,62,16]\n",
+ "\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list.reverse()\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list_2 = [2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n",
+ "for item in dummy_list_2:\n",
+ " dummy_list.append(item)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_dict={16:2, 62:1, 98:1, 82:1, 23:1, 2:1, 200:1, 4:1, 1:1, 0:1, 9.45:1, 45.67:1, 90:1, 12.01:1, 12.02:1}\n",
+ "\n",
+ "print (dummy_dict)\n",
+ "\n",
+ "dummy_list.sort()\n",
+ "print (dummy_list)\n",
+ "dummy_list.sort(reverse=True)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "x = 16\n",
+ "dummy_list.remove(x)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "x=int(input())\n",
+ "del dummy_list[x]\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list.clear()\n",
+ "print (dummy_list)"
+ ],
+ "execution_count": 0,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[23, 82, 98, 62, 16]\n",
+ "[16, 62, 98, 82, 23]\n",
+ "[16, 62, 98, 82, 23, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n",
+ "{16: 2, 62: 1, 98: 1, 82: 1, 23: 1, 2: 1, 200: 1, 4: 1, 1: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1, 12.01: 1, 12.02: 1}\n",
+ "[0, 1, 2, 4, 9.45, 12.01, 12.02, 16, 16, 23, 45.67, 62, 82, 90, 98, 200]\n",
+ "[200, 98, 90, 82, 62, 45.67, 23, 16, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "[200, 98, 90, 82, 62, 45.67, 23, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "3\n",
+ "[200, 98, 90, 62, 45.67, 23, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "[]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Get_to_know_your_Data.ipynb b/Get_to_know_your_Data.ipynb
new file mode 100644
index 0000000..9065529
--- /dev/null
+++ b/Get_to_know_your_Data.ipynb
@@ -0,0 +1,2354 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "Get to know your Data.ipynb",
+ "version": "0.3.2",
+ "provenance": [],
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "[View in Colaboratory](https://colab.research.google.com/github/dnc2k/Assignment-2/blob/dnc2k/Get_to_know_your_Data.ipynb)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "J82LU53m_OU0",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "# Get to know your Data\n",
+ "\n",
+ "\n",
+ "#### Import necessary modules\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "ZyO1UXL8mtSj",
+ "colab_type": "code",
+ "colab": {}
+ },
+ "cell_type": "code",
+ "source": [
+ "import pandas as pd\n",
+ "import numpy as np"
+ ],
+ "execution_count": 0,
+ "outputs": []
+ },
+ {
+ "metadata": {
+ "id": "yXTzTowtnwGI",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Loading CSV Data to a DataFrame"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "H1Bjlb5wm9f-",
+ "colab_type": "code",
+ "colab": {}
+ },
+ "cell_type": "code",
+ "source": [
+ "iris_df = pd.read_csv('https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv')\n"
+ ],
+ "execution_count": 0,
+ "outputs": []
+ },
+ {
+ "metadata": {
+ "id": "KE-k7b_Mn5iN",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### See the top 10 rows\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "HY2Ps7xMn4ao",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "outputId": "b3885b8d-976d-4d86-b736-455a1b4dacbd"
+ },
+ "cell_type": "code",
+ "source": [
+ "iris_df.head()"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 5.1 | \n",
+ " 3.5 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 4.9 | \n",
+ " 3.0 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 4.7 | \n",
+ " 3.2 | \n",
+ " 1.3 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 4.6 | \n",
+ " 3.1 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5.0 | \n",
+ " 3.6 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "0 5.1 3.5 1.4 0.2 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "2 4.7 3.2 1.3 0.2 setosa\n",
+ "3 4.6 3.1 1.5 0.2 setosa\n",
+ "4 5.0 3.6 1.4 0.2 setosa"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 3
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "ZQXekIodqOZu",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Find number of rows and columns\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "6Y-A-lbFqR82",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 72
+ },
+ "outputId": "16f316ca-d432-4e85-c69e-858b96ac6223"
+ },
+ "cell_type": "code",
+ "source": [
+ "print(iris_df.shape)\n",
+ "\n",
+ "#first is row and second is column\n",
+ "#select row by simple indexing\n",
+ "\n",
+ "print(iris_df.shape[0])\n",
+ "print(iris_df.shape[1])"
+ ],
+ "execution_count": 5,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "(150, 5)\n",
+ "150\n",
+ "5\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "4ckCiGPhrC_t",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Print all columns"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "S6jgMyRDrF2a",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 72
+ },
+ "outputId": "fafa4cc7-b62d-4f89-80c2-9675b7e27275"
+ },
+ "cell_type": "code",
+ "source": [
+ "print(iris_df.columns)"
+ ],
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "Index(['sepal_length', 'sepal_width', 'petal_length', 'petal_width',\n",
+ " 'species'],\n",
+ " dtype='object')\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "kVav5-ACtIqS",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Check Index\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "iu3I9zIGtLDX",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "bb648e8c-d63a-48a6-d120-ecb0fa35dc9b"
+ },
+ "cell_type": "code",
+ "source": [
+ "print(iris_df.index)"
+ ],
+ "execution_count": 7,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "RangeIndex(start=0, stop=150, step=1)\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "psCc7PborOCQ",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Right now the iris_data set has all the species grouped together let's shuffle it"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "Bxc8i6avrZPw",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 237
+ },
+ "outputId": "83f93cef-be1a-446d-e113-7dd23d70f087"
+ },
+ "cell_type": "code",
+ "source": [
+ "#generate a random permutaion on index\n",
+ "\n",
+ "print(iris_df.head())\n",
+ "\n",
+ "new_index = np.random.permutation(iris_df.index)\n",
+ "iris_df = iris_df.reindex(index = new_index)\n",
+ "\n",
+ "print(iris_df.head())"
+ ],
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "0 5.1 3.5 1.4 0.2 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "2 4.7 3.2 1.3 0.2 setosa\n",
+ "3 4.6 3.1 1.5 0.2 setosa\n",
+ "4 5.0 3.6 1.4 0.2 setosa\n",
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "97 6.2 2.9 4.3 1.3 versicolor\n",
+ "103 6.3 2.9 5.6 1.8 virginica\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "58 6.6 2.9 4.6 1.3 versicolor\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "j32h8022sRT8",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### We can also apply an operation on whole column of iris_df"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "seYXHXsYsYJI",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 348
+ },
+ "outputId": "1101114c-d7bc-4667-ec14-a215ed860945"
+ },
+ "cell_type": "code",
+ "source": [
+ "#original\n",
+ "\n",
+ "print(iris_df.head())\n",
+ "\n",
+ "iris_df['sepal_width'] *= 10\n",
+ "\n",
+ "#changed\n",
+ "\n",
+ "print(iris_df.head())\n",
+ "\n",
+ "#lets undo the operation\n",
+ "\n",
+ "iris_df['sepal_width'] /= 10\n",
+ "\n",
+ "print(iris_df.head())"
+ ],
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "97 6.2 2.9 4.3 1.3 versicolor\n",
+ "103 6.3 2.9 5.6 1.8 virginica\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "58 6.6 2.9 4.6 1.3 versicolor\n",
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "97 6.2 29.0 4.3 1.3 versicolor\n",
+ "103 6.3 29.0 5.6 1.8 virginica\n",
+ "6 4.6 34.0 1.4 0.3 setosa\n",
+ "1 4.9 30.0 1.4 0.2 setosa\n",
+ "58 6.6 29.0 4.6 1.3 versicolor\n",
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "97 6.2 2.9 4.3 1.3 versicolor\n",
+ "103 6.3 2.9 5.6 1.8 virginica\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "58 6.6 2.9 4.6 1.3 versicolor\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "R-Ca-LBLzjiF",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Show all the rows where sepal_width > 3.3"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "WJ7W-F-d0AoZ",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1179
+ },
+ "outputId": "f304de3d-0e95-4b9f-c3d5-e835e62d33f8"
+ },
+ "cell_type": "code",
+ "source": [
+ "iris_df[iris_df['sepal_width']>3.3]"
+ ],
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 6 | \n",
+ " 4.6 | \n",
+ " 3.4 | \n",
+ " 1.4 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 33 | \n",
+ " 5.5 | \n",
+ " 4.2 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 5.4 | \n",
+ " 3.9 | \n",
+ " 1.3 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 44 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.9 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 36 | \n",
+ " 5.5 | \n",
+ " 3.5 | \n",
+ " 1.3 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 40 | \n",
+ " 5.0 | \n",
+ " 3.5 | \n",
+ " 1.3 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 27 | \n",
+ " 5.2 | \n",
+ " 3.5 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 20 | \n",
+ " 5.4 | \n",
+ " 3.4 | \n",
+ " 1.7 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.5 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 148 | \n",
+ " 6.2 | \n",
+ " 3.4 | \n",
+ " 5.4 | \n",
+ " 2.3 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 43 | \n",
+ " 5.0 | \n",
+ " 3.5 | \n",
+ " 1.6 | \n",
+ " 0.6 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 131 | \n",
+ " 7.9 | \n",
+ " 3.8 | \n",
+ " 6.4 | \n",
+ " 2.0 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 117 | \n",
+ " 7.7 | \n",
+ " 3.8 | \n",
+ " 6.7 | \n",
+ " 2.2 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 31 | \n",
+ " 5.4 | \n",
+ " 3.4 | \n",
+ " 1.5 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 22 | \n",
+ " 4.6 | \n",
+ " 3.6 | \n",
+ " 1.0 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 21 | \n",
+ " 5.1 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 85 | \n",
+ " 6.0 | \n",
+ " 3.4 | \n",
+ " 4.5 | \n",
+ " 1.6 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 39 | \n",
+ " 5.1 | \n",
+ " 3.4 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 5.8 | \n",
+ " 4.0 | \n",
+ " 1.2 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 0 | \n",
+ " 5.1 | \n",
+ " 3.5 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5.0 | \n",
+ " 3.6 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 26 | \n",
+ " 5.0 | \n",
+ " 3.4 | \n",
+ " 1.6 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 5.7 | \n",
+ " 3.8 | \n",
+ " 1.7 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 109 | \n",
+ " 7.2 | \n",
+ " 3.6 | \n",
+ " 6.1 | \n",
+ " 2.5 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 5.7 | \n",
+ " 4.4 | \n",
+ " 1.5 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 24 | \n",
+ " 4.8 | \n",
+ " 3.4 | \n",
+ " 1.9 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 28 | \n",
+ " 5.2 | \n",
+ " 3.4 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 5.0 | \n",
+ " 3.4 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 4.8 | \n",
+ " 3.4 | \n",
+ " 1.6 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 32 | \n",
+ " 5.2 | \n",
+ " 4.1 | \n",
+ " 1.5 | \n",
+ " 0.1 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 136 | \n",
+ " 6.3 | \n",
+ " 3.4 | \n",
+ " 5.6 | \n",
+ " 2.4 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 5.1 | \n",
+ " 3.5 | \n",
+ " 1.4 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 5.4 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 5.4 | \n",
+ " 3.9 | \n",
+ " 1.7 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 48 | \n",
+ " 5.3 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 46 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.6 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "33 5.5 4.2 1.4 0.2 setosa\n",
+ "16 5.4 3.9 1.3 0.4 setosa\n",
+ "44 5.1 3.8 1.9 0.4 setosa\n",
+ "36 5.5 3.5 1.3 0.2 setosa\n",
+ "40 5.0 3.5 1.3 0.3 setosa\n",
+ "27 5.2 3.5 1.5 0.2 setosa\n",
+ "20 5.4 3.4 1.7 0.2 setosa\n",
+ "19 5.1 3.8 1.5 0.3 setosa\n",
+ "148 6.2 3.4 5.4 2.3 virginica\n",
+ "43 5.0 3.5 1.6 0.6 setosa\n",
+ "131 7.9 3.8 6.4 2.0 virginica\n",
+ "117 7.7 3.8 6.7 2.2 virginica\n",
+ "31 5.4 3.4 1.5 0.4 setosa\n",
+ "22 4.6 3.6 1.0 0.2 setosa\n",
+ "21 5.1 3.7 1.5 0.4 setosa\n",
+ "85 6.0 3.4 4.5 1.6 versicolor\n",
+ "39 5.1 3.4 1.5 0.2 setosa\n",
+ "14 5.8 4.0 1.2 0.2 setosa\n",
+ "0 5.1 3.5 1.4 0.2 setosa\n",
+ "4 5.0 3.6 1.4 0.2 setosa\n",
+ "26 5.0 3.4 1.6 0.4 setosa\n",
+ "18 5.7 3.8 1.7 0.3 setosa\n",
+ "109 7.2 3.6 6.1 2.5 virginica\n",
+ "15 5.7 4.4 1.5 0.4 setosa\n",
+ "24 4.8 3.4 1.9 0.2 setosa\n",
+ "28 5.2 3.4 1.4 0.2 setosa\n",
+ "7 5.0 3.4 1.5 0.2 setosa\n",
+ "11 4.8 3.4 1.6 0.2 setosa\n",
+ "32 5.2 4.1 1.5 0.1 setosa\n",
+ "136 6.3 3.4 5.6 2.4 virginica\n",
+ "17 5.1 3.5 1.4 0.3 setosa\n",
+ "10 5.4 3.7 1.5 0.2 setosa\n",
+ "5 5.4 3.9 1.7 0.4 setosa\n",
+ "48 5.3 3.7 1.5 0.2 setosa\n",
+ "46 5.1 3.8 1.6 0.2 setosa"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 10
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "gH3DnhCq2Cbl",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Club two filters together - Find all samples where sepal_width > 3.3 and species is versicolor"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "4U7ksr_R2H7M",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 81
+ },
+ "outputId": "b1b304dc-251b-42d8-b214-25f51493e578"
+ },
+ "cell_type": "code",
+ "source": [
+ "iris_df[(iris_df['sepal_width']>3.3) & (iris_df['species'] == 'versicolor')] "
+ ],
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 85 | \n",
+ " 6.0 | \n",
+ " 3.4 | \n",
+ " 4.5 | \n",
+ " 1.6 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "85 6.0 3.4 4.5 1.6 versicolor"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 11
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "1lmnB3ot2u7I",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Sorting a column by value"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "K7KIj6fv2zWP",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1992
+ },
+ "outputId": "9c54e5a0-60ce-4853-f6c7-5311daa91e60"
+ },
+ "cell_type": "code",
+ "source": [
+ "iris_df.sort_values(by='sepal_width')#, ascending = False)\n",
+ "#pass ascending = False for descending order"
+ ],
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 60 | \n",
+ " 5.0 | \n",
+ " 2.0 | \n",
+ " 3.5 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 119 | \n",
+ " 6.0 | \n",
+ " 2.2 | \n",
+ " 5.0 | \n",
+ " 1.5 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 68 | \n",
+ " 6.2 | \n",
+ " 2.2 | \n",
+ " 4.5 | \n",
+ " 1.5 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 62 | \n",
+ " 6.0 | \n",
+ " 2.2 | \n",
+ " 4.0 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 53 | \n",
+ " 5.5 | \n",
+ " 2.3 | \n",
+ " 4.0 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 87 | \n",
+ " 6.3 | \n",
+ " 2.3 | \n",
+ " 4.4 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 93 | \n",
+ " 5.0 | \n",
+ " 2.3 | \n",
+ " 3.3 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 41 | \n",
+ " 4.5 | \n",
+ " 2.3 | \n",
+ " 1.3 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 57 | \n",
+ " 4.9 | \n",
+ " 2.4 | \n",
+ " 3.3 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 81 | \n",
+ " 5.5 | \n",
+ " 2.4 | \n",
+ " 3.7 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 80 | \n",
+ " 5.5 | \n",
+ " 2.4 | \n",
+ " 3.8 | \n",
+ " 1.1 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 89 | \n",
+ " 5.5 | \n",
+ " 2.5 | \n",
+ " 4.0 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 108 | \n",
+ " 6.7 | \n",
+ " 2.5 | \n",
+ " 5.8 | \n",
+ " 1.8 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 98 | \n",
+ " 5.1 | \n",
+ " 2.5 | \n",
+ " 3.0 | \n",
+ " 1.1 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 146 | \n",
+ " 6.3 | \n",
+ " 2.5 | \n",
+ " 5.0 | \n",
+ " 1.9 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 106 | \n",
+ " 4.9 | \n",
+ " 2.5 | \n",
+ " 4.5 | \n",
+ " 1.7 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 72 | \n",
+ " 6.3 | \n",
+ " 2.5 | \n",
+ " 4.9 | \n",
+ " 1.5 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 69 | \n",
+ " 5.6 | \n",
+ " 2.5 | \n",
+ " 3.9 | \n",
+ " 1.1 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 113 | \n",
+ " 5.7 | \n",
+ " 2.5 | \n",
+ " 5.0 | \n",
+ " 2.0 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 90 | \n",
+ " 5.5 | \n",
+ " 2.6 | \n",
+ " 4.4 | \n",
+ " 1.2 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 118 | \n",
+ " 7.7 | \n",
+ " 2.6 | \n",
+ " 6.9 | \n",
+ " 2.3 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 79 | \n",
+ " 5.7 | \n",
+ " 2.6 | \n",
+ " 3.5 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 134 | \n",
+ " 6.1 | \n",
+ " 2.6 | \n",
+ " 5.6 | \n",
+ " 1.4 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 92 | \n",
+ " 5.8 | \n",
+ " 2.6 | \n",
+ " 4.0 | \n",
+ " 1.2 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 82 | \n",
+ " 5.8 | \n",
+ " 2.7 | \n",
+ " 3.9 | \n",
+ " 1.2 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 59 | \n",
+ " 5.2 | \n",
+ " 2.7 | \n",
+ " 3.9 | \n",
+ " 1.4 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 111 | \n",
+ " 6.4 | \n",
+ " 2.7 | \n",
+ " 5.3 | \n",
+ " 1.9 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 94 | \n",
+ " 5.6 | \n",
+ " 2.7 | \n",
+ " 4.2 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 101 | \n",
+ " 5.8 | \n",
+ " 2.7 | \n",
+ " 5.1 | \n",
+ " 1.9 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 67 | \n",
+ " 5.8 | \n",
+ " 2.7 | \n",
+ " 4.1 | \n",
+ " 1.0 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 20 | \n",
+ " 5.4 | \n",
+ " 3.4 | \n",
+ " 1.7 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 148 | \n",
+ " 6.2 | \n",
+ " 3.4 | \n",
+ " 5.4 | \n",
+ " 2.3 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 39 | \n",
+ " 5.1 | \n",
+ " 3.4 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 85 | \n",
+ " 6.0 | \n",
+ " 3.4 | \n",
+ " 4.5 | \n",
+ " 1.6 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 4.6 | \n",
+ " 3.4 | \n",
+ " 1.4 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 24 | \n",
+ " 4.8 | \n",
+ " 3.4 | \n",
+ " 1.9 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 36 | \n",
+ " 5.5 | \n",
+ " 3.5 | \n",
+ " 1.3 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 27 | \n",
+ " 5.2 | \n",
+ " 3.5 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 0 | \n",
+ " 5.1 | \n",
+ " 3.5 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 17 | \n",
+ " 5.1 | \n",
+ " 3.5 | \n",
+ " 1.4 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 43 | \n",
+ " 5.0 | \n",
+ " 3.5 | \n",
+ " 1.6 | \n",
+ " 0.6 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 40 | \n",
+ " 5.0 | \n",
+ " 3.5 | \n",
+ " 1.3 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 22 | \n",
+ " 4.6 | \n",
+ " 3.6 | \n",
+ " 1.0 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 109 | \n",
+ " 7.2 | \n",
+ " 3.6 | \n",
+ " 6.1 | \n",
+ " 2.5 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 5.0 | \n",
+ " 3.6 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 21 | \n",
+ " 5.1 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 5.4 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 48 | \n",
+ " 5.3 | \n",
+ " 3.7 | \n",
+ " 1.5 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 46 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.6 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 44 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.9 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 117 | \n",
+ " 7.7 | \n",
+ " 3.8 | \n",
+ " 6.7 | \n",
+ " 2.2 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 18 | \n",
+ " 5.7 | \n",
+ " 3.8 | \n",
+ " 1.7 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 19 | \n",
+ " 5.1 | \n",
+ " 3.8 | \n",
+ " 1.5 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 131 | \n",
+ " 7.9 | \n",
+ " 3.8 | \n",
+ " 6.4 | \n",
+ " 2.0 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 5.4 | \n",
+ " 3.9 | \n",
+ " 1.7 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 16 | \n",
+ " 5.4 | \n",
+ " 3.9 | \n",
+ " 1.3 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 5.8 | \n",
+ " 4.0 | \n",
+ " 1.2 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 32 | \n",
+ " 5.2 | \n",
+ " 4.1 | \n",
+ " 1.5 | \n",
+ " 0.1 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 33 | \n",
+ " 5.5 | \n",
+ " 4.2 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 15 | \n",
+ " 5.7 | \n",
+ " 4.4 | \n",
+ " 1.5 | \n",
+ " 0.4 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
150 rows × 5 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "60 5.0 2.0 3.5 1.0 versicolor\n",
+ "119 6.0 2.2 5.0 1.5 virginica\n",
+ "68 6.2 2.2 4.5 1.5 versicolor\n",
+ "62 6.0 2.2 4.0 1.0 versicolor\n",
+ "53 5.5 2.3 4.0 1.3 versicolor\n",
+ "87 6.3 2.3 4.4 1.3 versicolor\n",
+ "93 5.0 2.3 3.3 1.0 versicolor\n",
+ "41 4.5 2.3 1.3 0.3 setosa\n",
+ "57 4.9 2.4 3.3 1.0 versicolor\n",
+ "81 5.5 2.4 3.7 1.0 versicolor\n",
+ "80 5.5 2.4 3.8 1.1 versicolor\n",
+ "89 5.5 2.5 4.0 1.3 versicolor\n",
+ "108 6.7 2.5 5.8 1.8 virginica\n",
+ "98 5.1 2.5 3.0 1.1 versicolor\n",
+ "146 6.3 2.5 5.0 1.9 virginica\n",
+ "106 4.9 2.5 4.5 1.7 virginica\n",
+ "72 6.3 2.5 4.9 1.5 versicolor\n",
+ "69 5.6 2.5 3.9 1.1 versicolor\n",
+ "113 5.7 2.5 5.0 2.0 virginica\n",
+ "90 5.5 2.6 4.4 1.2 versicolor\n",
+ "118 7.7 2.6 6.9 2.3 virginica\n",
+ "79 5.7 2.6 3.5 1.0 versicolor\n",
+ "134 6.1 2.6 5.6 1.4 virginica\n",
+ "92 5.8 2.6 4.0 1.2 versicolor\n",
+ "82 5.8 2.7 3.9 1.2 versicolor\n",
+ "59 5.2 2.7 3.9 1.4 versicolor\n",
+ "111 6.4 2.7 5.3 1.9 virginica\n",
+ "94 5.6 2.7 4.2 1.3 versicolor\n",
+ "101 5.8 2.7 5.1 1.9 virginica\n",
+ "67 5.8 2.7 4.1 1.0 versicolor\n",
+ ".. ... ... ... ... ...\n",
+ "20 5.4 3.4 1.7 0.2 setosa\n",
+ "148 6.2 3.4 5.4 2.3 virginica\n",
+ "39 5.1 3.4 1.5 0.2 setosa\n",
+ "85 6.0 3.4 4.5 1.6 versicolor\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "24 4.8 3.4 1.9 0.2 setosa\n",
+ "36 5.5 3.5 1.3 0.2 setosa\n",
+ "27 5.2 3.5 1.5 0.2 setosa\n",
+ "0 5.1 3.5 1.4 0.2 setosa\n",
+ "17 5.1 3.5 1.4 0.3 setosa\n",
+ "43 5.0 3.5 1.6 0.6 setosa\n",
+ "40 5.0 3.5 1.3 0.3 setosa\n",
+ "22 4.6 3.6 1.0 0.2 setosa\n",
+ "109 7.2 3.6 6.1 2.5 virginica\n",
+ "4 5.0 3.6 1.4 0.2 setosa\n",
+ "21 5.1 3.7 1.5 0.4 setosa\n",
+ "10 5.4 3.7 1.5 0.2 setosa\n",
+ "48 5.3 3.7 1.5 0.2 setosa\n",
+ "46 5.1 3.8 1.6 0.2 setosa\n",
+ "44 5.1 3.8 1.9 0.4 setosa\n",
+ "117 7.7 3.8 6.7 2.2 virginica\n",
+ "18 5.7 3.8 1.7 0.3 setosa\n",
+ "19 5.1 3.8 1.5 0.3 setosa\n",
+ "131 7.9 3.8 6.4 2.0 virginica\n",
+ "5 5.4 3.9 1.7 0.4 setosa\n",
+ "16 5.4 3.9 1.3 0.4 setosa\n",
+ "14 5.8 4.0 1.2 0.2 setosa\n",
+ "32 5.2 4.1 1.5 0.1 setosa\n",
+ "33 5.5 4.2 1.4 0.2 setosa\n",
+ "15 5.7 4.4 1.5 0.4 setosa\n",
+ "\n",
+ "[150 rows x 5 columns]"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 12
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "9jg_Z4YCoMSV",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### List all the unique species"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "M6EN78ufoJY7",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "a2e0fe49-7270-4b54-8f3f-2329a6024c84"
+ },
+ "cell_type": "code",
+ "source": [
+ "species = iris_df['species'].unique()\n",
+ "\n",
+ "print(species)"
+ ],
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "['versicolor' 'virginica' 'setosa']\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "wG1i5nxBodmB",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Selecting a particular species using boolean mask (learnt in previous exercise)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "gZvpbKBwoVUe",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "outputId": "ebf829ba-a0de-4393-a898-5b2d8fc62991"
+ },
+ "cell_type": "code",
+ "source": [
+ "setosa = iris_df[iris_df['species'] == species[0]]\n",
+ "\n",
+ "setosa.head()"
+ ],
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 97 | \n",
+ " 6.2 | \n",
+ " 2.9 | \n",
+ " 4.3 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 58 | \n",
+ " 6.6 | \n",
+ " 2.9 | \n",
+ " 4.6 | \n",
+ " 1.3 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 76 | \n",
+ " 6.8 | \n",
+ " 2.8 | \n",
+ " 4.8 | \n",
+ " 1.4 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 95 | \n",
+ " 5.7 | \n",
+ " 3.0 | \n",
+ " 4.2 | \n",
+ " 1.2 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ " | 84 | \n",
+ " 5.4 | \n",
+ " 3.0 | \n",
+ " 4.5 | \n",
+ " 1.5 | \n",
+ " versicolor | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "97 6.2 2.9 4.3 1.3 versicolor\n",
+ "58 6.6 2.9 4.6 1.3 versicolor\n",
+ "76 6.8 2.8 4.8 1.4 versicolor\n",
+ "95 5.7 3.0 4.2 1.2 versicolor\n",
+ "84 5.4 3.0 4.5 1.5 versicolor"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 14
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "7tumfZ3DotPG",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "outputId": "ed1e77a9-5413-40d5-9af7-5f6d31b60128"
+ },
+ "cell_type": "code",
+ "source": [
+ "# do the same for other 2 species \n",
+ "versicolor = iris_df[iris_df['species'] == species[1]]\n",
+ "\n",
+ "versicolor.head()"
+ ],
+ "execution_count": 15,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 103 | \n",
+ " 6.3 | \n",
+ " 2.9 | \n",
+ " 5.6 | \n",
+ " 1.8 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 112 | \n",
+ " 6.8 | \n",
+ " 3.0 | \n",
+ " 5.5 | \n",
+ " 2.1 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 124 | \n",
+ " 6.7 | \n",
+ " 3.3 | \n",
+ " 5.7 | \n",
+ " 2.1 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 133 | \n",
+ " 6.3 | \n",
+ " 2.8 | \n",
+ " 5.1 | \n",
+ " 1.5 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ " | 148 | \n",
+ " 6.2 | \n",
+ " 3.4 | \n",
+ " 5.4 | \n",
+ " 2.3 | \n",
+ " virginica | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "103 6.3 2.9 5.6 1.8 virginica\n",
+ "112 6.8 3.0 5.5 2.1 virginica\n",
+ "124 6.7 3.3 5.7 2.1 virginica\n",
+ "133 6.3 2.8 5.1 1.5 virginica\n",
+ "148 6.2 3.4 5.4 2.3 virginica"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 15
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "cUYm5UqVpDPy",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 206
+ },
+ "outputId": "bda8d3a2-07b1-4b58-99f7-82380218806f"
+ },
+ "cell_type": "code",
+ "source": [
+ "\n",
+ "\n",
+ "virginica = iris_df[iris_df['species'] == species[2]]\n",
+ "\n",
+ "virginica.head()"
+ ],
+ "execution_count": 16,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ " species | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 6 | \n",
+ " 4.6 | \n",
+ " 3.4 | \n",
+ " 1.4 | \n",
+ " 0.3 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 4.9 | \n",
+ " 3.0 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 33 | \n",
+ " 5.5 | \n",
+ " 4.2 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 4.4 | \n",
+ " 2.9 | \n",
+ " 1.4 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ " | 38 | \n",
+ " 4.4 | \n",
+ " 3.0 | \n",
+ " 1.3 | \n",
+ " 0.2 | \n",
+ " setosa | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width species\n",
+ "6 4.6 3.4 1.4 0.3 setosa\n",
+ "1 4.9 3.0 1.4 0.2 setosa\n",
+ "33 5.5 4.2 1.4 0.2 setosa\n",
+ "8 4.4 2.9 1.4 0.2 setosa\n",
+ "38 4.4 3.0 1.3 0.2 setosa"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 16
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "-y1wDc8SpdQs",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Describe each created species to see the difference\n",
+ "\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "eHrn3ZVRpOk5",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 300
+ },
+ "outputId": "bac6caca-dbfb-492e-8f17-bce2825a6451"
+ },
+ "cell_type": "code",
+ "source": [
+ "setosa.describe()"
+ ],
+ "execution_count": 17,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | count | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ "
\n",
+ " \n",
+ " | mean | \n",
+ " 5.936000 | \n",
+ " 2.770000 | \n",
+ " 4.260000 | \n",
+ " 1.326000 | \n",
+ "
\n",
+ " \n",
+ " | std | \n",
+ " 0.516171 | \n",
+ " 0.313798 | \n",
+ " 0.469911 | \n",
+ " 0.197753 | \n",
+ "
\n",
+ " \n",
+ " | min | \n",
+ " 4.900000 | \n",
+ " 2.000000 | \n",
+ " 3.000000 | \n",
+ " 1.000000 | \n",
+ "
\n",
+ " \n",
+ " | 25% | \n",
+ " 5.600000 | \n",
+ " 2.525000 | \n",
+ " 4.000000 | \n",
+ " 1.200000 | \n",
+ "
\n",
+ " \n",
+ " | 50% | \n",
+ " 5.900000 | \n",
+ " 2.800000 | \n",
+ " 4.350000 | \n",
+ " 1.300000 | \n",
+ "
\n",
+ " \n",
+ " | 75% | \n",
+ " 6.300000 | \n",
+ " 3.000000 | \n",
+ " 4.600000 | \n",
+ " 1.500000 | \n",
+ "
\n",
+ " \n",
+ " | max | \n",
+ " 7.000000 | \n",
+ " 3.400000 | \n",
+ " 5.100000 | \n",
+ " 1.800000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width\n",
+ "count 50.000000 50.000000 50.000000 50.000000\n",
+ "mean 5.936000 2.770000 4.260000 1.326000\n",
+ "std 0.516171 0.313798 0.469911 0.197753\n",
+ "min 4.900000 2.000000 3.000000 1.000000\n",
+ "25% 5.600000 2.525000 4.000000 1.200000\n",
+ "50% 5.900000 2.800000 4.350000 1.300000\n",
+ "75% 6.300000 3.000000 4.600000 1.500000\n",
+ "max 7.000000 3.400000 5.100000 1.800000"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 17
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "GwJFT2GlpwUv",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 300
+ },
+ "outputId": "f3bc1793-3de4-44ed-dc79-35ac4e28c423"
+ },
+ "cell_type": "code",
+ "source": [
+ "versicolor.describe()"
+ ],
+ "execution_count": 18,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | count | \n",
+ " 50.00000 | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ " 50.00000 | \n",
+ "
\n",
+ " \n",
+ " | mean | \n",
+ " 6.58800 | \n",
+ " 2.974000 | \n",
+ " 5.552000 | \n",
+ " 2.02600 | \n",
+ "
\n",
+ " \n",
+ " | std | \n",
+ " 0.63588 | \n",
+ " 0.322497 | \n",
+ " 0.551895 | \n",
+ " 0.27465 | \n",
+ "
\n",
+ " \n",
+ " | min | \n",
+ " 4.90000 | \n",
+ " 2.200000 | \n",
+ " 4.500000 | \n",
+ " 1.40000 | \n",
+ "
\n",
+ " \n",
+ " | 25% | \n",
+ " 6.22500 | \n",
+ " 2.800000 | \n",
+ " 5.100000 | \n",
+ " 1.80000 | \n",
+ "
\n",
+ " \n",
+ " | 50% | \n",
+ " 6.50000 | \n",
+ " 3.000000 | \n",
+ " 5.550000 | \n",
+ " 2.00000 | \n",
+ "
\n",
+ " \n",
+ " | 75% | \n",
+ " 6.90000 | \n",
+ " 3.175000 | \n",
+ " 5.875000 | \n",
+ " 2.30000 | \n",
+ "
\n",
+ " \n",
+ " | max | \n",
+ " 7.90000 | \n",
+ " 3.800000 | \n",
+ " 6.900000 | \n",
+ " 2.50000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width\n",
+ "count 50.00000 50.000000 50.000000 50.00000\n",
+ "mean 6.58800 2.974000 5.552000 2.02600\n",
+ "std 0.63588 0.322497 0.551895 0.27465\n",
+ "min 4.90000 2.200000 4.500000 1.40000\n",
+ "25% 6.22500 2.800000 5.100000 1.80000\n",
+ "50% 6.50000 3.000000 5.550000 2.00000\n",
+ "75% 6.90000 3.175000 5.875000 2.30000\n",
+ "max 7.90000 3.800000 6.900000 2.50000"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 18
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "Ad4qhSZLpztf",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 300
+ },
+ "outputId": "1bef7a2a-5454-4371-a158-775085a3905c"
+ },
+ "cell_type": "code",
+ "source": [
+ "virginica.describe()"
+ ],
+ "execution_count": 19,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " sepal_length | \n",
+ " sepal_width | \n",
+ " petal_length | \n",
+ " petal_width | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | count | \n",
+ " 50.00000 | \n",
+ " 50.000000 | \n",
+ " 50.000000 | \n",
+ " 50.00000 | \n",
+ "
\n",
+ " \n",
+ " | mean | \n",
+ " 5.00600 | \n",
+ " 3.418000 | \n",
+ " 1.464000 | \n",
+ " 0.24400 | \n",
+ "
\n",
+ " \n",
+ " | std | \n",
+ " 0.35249 | \n",
+ " 0.381024 | \n",
+ " 0.173511 | \n",
+ " 0.10721 | \n",
+ "
\n",
+ " \n",
+ " | min | \n",
+ " 4.30000 | \n",
+ " 2.300000 | \n",
+ " 1.000000 | \n",
+ " 0.10000 | \n",
+ "
\n",
+ " \n",
+ " | 25% | \n",
+ " 4.80000 | \n",
+ " 3.125000 | \n",
+ " 1.400000 | \n",
+ " 0.20000 | \n",
+ "
\n",
+ " \n",
+ " | 50% | \n",
+ " 5.00000 | \n",
+ " 3.400000 | \n",
+ " 1.500000 | \n",
+ " 0.20000 | \n",
+ "
\n",
+ " \n",
+ " | 75% | \n",
+ " 5.20000 | \n",
+ " 3.675000 | \n",
+ " 1.575000 | \n",
+ " 0.30000 | \n",
+ "
\n",
+ " \n",
+ " | max | \n",
+ " 5.80000 | \n",
+ " 4.400000 | \n",
+ " 1.900000 | \n",
+ " 0.60000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " sepal_length sepal_width petal_length petal_width\n",
+ "count 50.00000 50.000000 50.000000 50.00000\n",
+ "mean 5.00600 3.418000 1.464000 0.24400\n",
+ "std 0.35249 0.381024 0.173511 0.10721\n",
+ "min 4.30000 2.300000 1.000000 0.10000\n",
+ "25% 4.80000 3.125000 1.400000 0.20000\n",
+ "50% 5.00000 3.400000 1.500000 0.20000\n",
+ "75% 5.20000 3.675000 1.575000 0.30000\n",
+ "max 5.80000 4.400000 1.900000 0.60000"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 19
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "Vdu0ulZWtr09",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Let's plot and see the difference"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "PEVMzRvpttmD",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "##### import matplotlib.pyplot "
+ ]
+ },
+ {
+ "metadata": {
+ "id": "rqDXuuAtt7C3",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 402
+ },
+ "outputId": "021c56dd-a9fb-4313-e553-f75a57683298"
+ },
+ "cell_type": "code",
+ "source": [
+ "import matplotlib.pyplot as plt\n",
+ "\n",
+ "#hist creates a histogram there are many more plots(see the documentation) you can play with it.\n",
+ "\n",
+ "plt.hist(setosa['sepal_length'])\n",
+ "plt.hist(versicolor['sepal_length'])\n",
+ "plt.hist(virginica['sepal_length'])"
+ ],
+ "execution_count": 20,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "(array([ 4., 1., 6., 5., 12., 8., 4., 5., 2., 3.]),\n",
+ " array([4.3 , 4.45, 4.6 , 4.75, 4.9 , 5.05, 5.2 , 5.35, 5.5 , 5.65, 5.8 ]),\n",
+ " )"
+ ]
+ },
+ "metadata": {
+ "tags": []
+ },
+ "execution_count": 20
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAd8AAAFKCAYAAABcq1WoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxv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csi4t8vUX74\n4Yct/1P0c5/7XJw+fToOHDgQFy9ejC1btsTQocX1awBaW18p7F9ExLBhw2L79u3x0UcfRWNjYzQ1\nNbW851QKe9ja+kplDyP+/Y1RZWXlx151+vKXvxx///vf4+TJk3HmzJnYuXNn3HPPPQWaMndXW98/\n//nPmDNnTmSz2bh48WLs3Lmz6Pawf//+sWvXroiIOHjwYFRWVrb8b+2O7l+Xfdn5StatWxdVVVUx\nevToGDFiREyYMCFuuOGG+NKXvlR0L3eNHDkyfvCDH8TmzZvjwoULsXDhwvjNb37Tsr6FCxfGnDlz\nIiLi4YcfjltvvbXAE7dPW+sr9v2L+Pez+7Fjx0ZdXV1ERMyfPz/Wr19fMnvY1vpKYQ8jPv7+/C9+\n8Yu49957Y+DAgTFnzpx46qmnoqysLGbOnBlVVfn/DXCdrbX19e3bN771rW9Ft27dYuTIkTFgwIAC\nTtp+EyZMiPr6+pgyZUpcvHgxFi5cmLf98/GSAJBYl33ZGQAKRXwBIDHxBYDExBcAEhNfAEhMfAEg\nMfEFgMTEFwAS+3/wQITBxOH0DQAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {
+ "tags": []
+ }
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Numpy_Examples_1.ipynb b/Numpy_Examples_1.ipynb
new file mode 100644
index 0000000..2827a4b
--- /dev/null
+++ b/Numpy_Examples_1.ipynb
@@ -0,0 +1,513 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "Numpy_Examples 1.ipynb",
+ "version": "0.3.2",
+ "provenance": [],
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "[View in Colaboratory](https://colab.research.google.com/github/dnc2k/Assignment-2/blob/dnc2k/Numpy_Examples_1.ipynb)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "3pSVAeWfuPcq",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "# Numpy Examples\n",
+ "\n",
+ "## What is numpy?\n",
+ "\n",
+ "#### Python has built-in:\n",
+ "\n",
+ "- containers: lists (costless insertion and append), dictionnaries (fast lookup)\n",
+ "- high-level number objects: integers, floating point\n",
+ "\n",
+ "#### Numpy is:\n",
+ "\n",
+ " - extension package to Python for multidimensional arrays\n",
+ " - closer to hardware (efficiency)\n",
+ " - designed for scientific computation (convenience)\n",
+ "\n",
+ "\n",
+ "#### Import numpy\n",
+ "\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "ozUi4_X55UHE",
+ "colab_type": "code",
+ "colab": {}
+ },
+ "cell_type": "code",
+ "source": [
+ "import numpy as np"
+ ],
+ "execution_count": 0,
+ "outputs": []
+ },
+ {
+ "metadata": {
+ "id": "3-1ghFDF5N2z",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "### Uncomment Print statement and run each cell to see the output\n",
+ "\n",
+ "#### Create numpy arrays\n"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "atYpk2ert0b-",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 90
+ },
+ "outputId": "4ff1f20c-14bb-4cb8-ceca-c7c1cd6a24c5"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.array([1, 2, 3]) # Create a rank 1 array\n",
+ "print(a)\n",
+ "print(type(a)) #print type of a\n",
+ "\n",
+ "b = np.array([[1,2,3],[4,5,6]]) # Create a rank 2 array\n",
+ "print(b.shape) # Prints \"(2, 3)\"\n",
+ "print(b[0, 0], b[0, 1], b[1, 0])"
+ ],
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[1 2 3]\n",
+ "\n",
+ "(2, 3)\n",
+ "1 2 4\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "Kro5ZOwXue5n",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Some basic functions for creating arrays. Print all the defined arrays and see the results."
+ ]
+ },
+ {
+ "metadata": {
+ "id": "V3rdzgr9uhHS",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 237
+ },
+ "outputId": "e25a51e1-4c70-4177-af60-164aa8901f45"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.zeros(shape=(2,2))\n",
+ "b = np.ones(shape = (3,3))\n",
+ "c = np.eye(2)\n",
+ "d = np.full(shape=(3,3), fill_value=5)\n",
+ "e = np.random.random((2,2))\n",
+ "\n",
+ "print('a', a)\n",
+ "print('b',b)\n",
+ "print('c',c)\n",
+ "print('d',d)\n",
+ "print('e',e)"
+ ],
+ "execution_count": 4,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "a [[0. 0.]\n",
+ " [0. 0.]]\n",
+ "b [[1. 1. 1.]\n",
+ " [1. 1. 1.]\n",
+ " [1. 1. 1.]]\n",
+ "c [[1. 0.]\n",
+ " [0. 1.]]\n",
+ "d [[5 5 5]\n",
+ " [5 5 5]\n",
+ " [5 5 5]]\n",
+ "e [[0.16463418 0.51575979]\n",
+ " [0.87927607 0.06306851]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "8RPW_SutukjF",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Execute and understand :)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "-8JuqYt4upeo",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 54
+ },
+ "outputId": "c54a2f16-6ccb-41f7-825d-21b527156b3d"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.arange(10)\n",
+ "b = np.linspace(0,10, num=6)\n",
+ "print(a)\n",
+ "print(b)"
+ ],
+ "execution_count": 17,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[0 1 2 3 4 5 6 7 8 9]\n",
+ "[ 0. 2. 4. 6. 8. 10.]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "MRHhbjx4uvYN",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Array Indexing"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "grF5_yUSuxVK",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 90
+ },
+ "outputId": "00a0aace-b1a6-4652-cadb-4fa881762e71"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])\n",
+ "\n",
+ "# Use slicing to pull out the subarray consisting of the first 2 rows\n",
+ "# and columns 1 and 2; b is the following array of shape (2, 2):\n",
+ "# [[2 3]\n",
+ "# [6 7]]\n",
+ "b = a[:2, 1:3]\n",
+ "print (b)\n",
+ "# A slice of an array is a view into the same data, so modifying it\n",
+ "# will modify the original array.\n",
+ "\n",
+ "print(a[0, 1]) # Prints \"2\"\n",
+ "\n",
+ "b[0, 0] = 77 # b[0, 0] is the same piece of data as a[0, 1]\n",
+ "print(a[0, 1]) # Prints \"77\""
+ ],
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[[2 3]\n",
+ " [6 7]]\n",
+ "2\n",
+ "77\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "s400Gijxu0kO",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Slicing"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "kubpegh2u4zF",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 127
+ },
+ "outputId": "79290990-bd7a-4cde-a777-34e3a6da9241"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])\n",
+ "\n",
+ "row_r1 = a[1, :] # Rank 1 view of the second row of a\n",
+ "row_r2 = a[1:2, :] # Rank 2 view of the second row of a\n",
+ "\n",
+ "print(row_r1, row_r1.shape) # Prints \"[5 6 7 8] (4,)\"\n",
+ "print(row_r2, row_r2.shape) # Prints \"[[5 6 7 8]] (1, 4)\"\n",
+ "\n",
+ "col_r1 = a[:, 1]\n",
+ "col_r2 = a[:, 1:2]\n",
+ "\n",
+ "print(col_r1, col_r1.shape) # Prints \"[ 2 6 10] (3,)\"\n",
+ "print(col_r2, col_r2.shape)"
+ ],
+ "execution_count": 10,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[5 6 7 8] (4,)\n",
+ "[[5 6 7 8]] (1, 4)\n",
+ "[ 2 6 10] (3,)\n",
+ "[[ 2]\n",
+ " [ 6]\n",
+ " [10]] (3, 1)\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "TmGnCO3AvE8t",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Aritmetic operations"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "YvBw3ImjvGqD",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 72
+ },
+ "outputId": "85c537ca-e089-4714-a430-911232c66ef1"
+ },
+ "cell_type": "code",
+ "source": [
+ "x = np.array([[1,2],[3,4]])\n",
+ "\n",
+ "print(np.sum(x)) # Compute sum of all elements; prints \"10\"\n",
+ "print(np.sum(x, axis=0)) # Compute sum of each column; prints \"[4 6]\"\n",
+ "print(np.sum(x, axis=1)) # Compute sum of each row; prints \"[3 7]\""
+ ],
+ "execution_count": 11,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "10\n",
+ "[4 6]\n",
+ "[3 7]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "uaVY3ZzD4pC2",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Using Boolean Mask"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "-PNfOMvh4_Gp",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 72
+ },
+ "outputId": "da128d9b-2bd3-4832-f0e9-1fc395281fbe"
+ },
+ "cell_type": "code",
+ "source": [
+ "b = np.arange(10)\n",
+ "\n",
+ "print(b)\n",
+ "\n",
+ "mask = b%2!=0 #perform computations on the list \n",
+ "\n",
+ "print(mask)\n",
+ "\n",
+ "print(b[mask]) #applying the mask on the numpy array\n"
+ ],
+ "execution_count": 12,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[0 1 2 3 4 5 6 7 8 9]\n",
+ "[False True False True False True False True False True]\n",
+ "[1 3 5 7 9]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "HbEPBbz-5J9K",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 35
+ },
+ "outputId": "bbf0f757-9b46-411d-a516-8ab550cb86bf"
+ },
+ "cell_type": "code",
+ "source": [
+ "modified_b = b\n",
+ "modified_b[mask] = -1\n",
+ "\n",
+ "print(modified_b)"
+ ],
+ "execution_count": 13,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[ 0 -1 2 -1 4 -1 6 -1 8 -1]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "zgSd71EEAHC7",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Swapping two columns in a 2d numpy array"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "-cvqeXd_AGo1",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 127
+ },
+ "outputId": "bed3a174-f512-4eb6-a7de-00a6e7a53087"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.arange(9).reshape(3,3)\n",
+ "print(a)\n",
+ "\n",
+ "print(a[:, [1,0,2]])"
+ ],
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[[0 1 2]\n",
+ " [3 4 5]\n",
+ " [6 7 8]]\n",
+ "[[1 0 2]\n",
+ " [4 3 5]\n",
+ " [7 6 8]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ },
+ {
+ "metadata": {
+ "id": "U7ifiLY3Ayky",
+ "colab_type": "text"
+ },
+ "cell_type": "markdown",
+ "source": [
+ "#### Swapping two rows in a 2d numpy array"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "0FrOURRDAZNP",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 127
+ },
+ "outputId": "0407ee33-bb36-42ac-e542-e0076bc3847d"
+ },
+ "cell_type": "code",
+ "source": [
+ "a = np.arange(9).reshape(3,3)\n",
+ "print(a)\n",
+ "\n",
+ "print(a[[1,0,2], :])"
+ ],
+ "execution_count": 16,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[[0 1 2]\n",
+ " [3 4 5]\n",
+ " [6 7 8]]\n",
+ "[[3 4 5]\n",
+ " [0 1 2]\n",
+ " [6 7 8]]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/dnc2k.ipynb b/dnc2k.ipynb
index 9e2543a..078df9a 100644
--- a/dnc2k.ipynb
+++ b/dnc2k.ipynb
@@ -1,32 +1,93 @@
{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "dnc2k.ipynb",
+ "version": "0.3.2",
+ "provenance": [],
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ }
},
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.5.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ "[View in Colaboratory](https://colab.research.google.com/github/dnc2k/Assignment-2/blob/dnc2k/dnc2k.ipynb)"
+ ]
+ },
+ {
+ "metadata": {
+ "id": "VSHhNc1q4AJF",
+ "colab_type": "code",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 201
+ },
+ "outputId": "eff259d6-8576-4bf5-ad11-6d59c2eb9bac"
+ },
+ "cell_type": "code",
+ "source": [
+ "dummy_list=[23,82,98,62,16]\n",
+ "\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list.reverse()\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list_2 = [2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n",
+ "for item in dummy_list_2:\n",
+ " dummy_list.append(item)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_dict={16:2, 62:1, 98:1, 82:1, 23:1, 2:1, 200:1, 4:1, 1:1, 0:1, 9.45:1, 45.67:1, 90:1, 12.01:1, 12.02:1}\n",
+ "\n",
+ "print (dummy_dict)\n",
+ "\n",
+ "dummy_list.sort()\n",
+ "print (dummy_list)\n",
+ "dummy_list.sort(reverse=True)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "x = 16\n",
+ "dummy_list.remove(x)\n",
+ "print (dummy_list)\n",
+ "\n",
+ "x=int(input())\n",
+ "del dummy_list[x]\n",
+ "print (dummy_list)\n",
+ "\n",
+ "dummy_list.clear()\n",
+ "print (dummy_list)"
+ ],
+ "execution_count": 1,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "text": [
+ "[23, 82, 98, 62, 16]\n",
+ "[16, 62, 98, 82, 23]\n",
+ "[16, 62, 98, 82, 23, 2, 200, 16, 4, 1, 0, 9.45, 45.67, 90, 12.01, 12.02]\n",
+ "{16: 2, 62: 1, 98: 1, 82: 1, 23: 1, 2: 1, 200: 1, 4: 1, 1: 1, 0: 1, 9.45: 1, 45.67: 1, 90: 1, 12.01: 1, 12.02: 1}\n",
+ "[0, 1, 2, 4, 9.45, 12.01, 12.02, 16, 16, 23, 45.67, 62, 82, 90, 98, 200]\n",
+ "[200, 98, 90, 82, 62, 45.67, 23, 16, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "[200, 98, 90, 82, 62, 45.67, 23, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "2\n",
+ "[200, 98, 82, 62, 45.67, 23, 16, 12.02, 12.01, 9.45, 4, 2, 1, 0]\n",
+ "[]\n"
+ ],
+ "name": "stdout"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file