Skip to content

VISHAL JENA ASSIGNMENT 2 PANDAS #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assignment1 Numpy.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Assignment1 Numpy.ipynb","provenance":[],"authorship_tag":"ABX9TyPjJhiw9UZMcdcNfMiL21DQ"},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"ig7-yF0L9ZYl","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598163531606,"user_tz":-330,"elapsed":2640,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"154c9eb2-3478-4fb9-b28d-a409e4c52c76"},"source":["# Q1 - create a list and convert into numpy and print it?\n","\n","import numpy as np\n","list = [1,2,3,4,5]\n","np.array(list)"],"execution_count":1,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([1, 2, 3, 4, 5])"]},"metadata":{"tags":[]},"execution_count":1}]},{"cell_type":"code","metadata":{"id":"dDi5cIDU9-wF","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":68},"executionInfo":{"status":"ok","timestamp":1598163715099,"user_tz":-330,"elapsed":1114,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"e0baec02-57c4-4c54-f685-e6c3d4800f36"},"source":["# Q2- make a 3x3 matrix , convert in into numpy array and then print it?\n","matrix = [[1,2,3],[4,5,6],[7,8,9]]\n","np.array(matrix)"],"execution_count":2,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[1, 2, 3],\n"," [4, 5, 6],\n"," [7, 8, 9]])"]},"metadata":{"tags":[]},"execution_count":2}]},{"cell_type":"code","metadata":{"id":"HcMkXlw6-v8T","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":68},"executionInfo":{"status":"ok","timestamp":1598165846560,"user_tz":-330,"elapsed":1311,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"7319facf-8b30-4969-f4c1-1e21db19ac32"},"source":["# Q3 - make a 3x3 matrix using arange,reshape?\n","arr = []\n","for i in range(1,18):\n"," if(i%2!=0):\n"," arr.append(i) # all i values is converted into list (name of list is arr)\n","arr2=np.array(arr) # arr2 list is converted into array\n","matrix1 = arr2.reshape(3,3)\n","matrix1\n","\n","\n","\n"],"execution_count":35,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[ 1, 3, 5],\n"," [ 7, 9, 11],\n"," [13, 15, 17]])"]},"metadata":{"tags":[]},"execution_count":35}]},{"cell_type":"code","metadata":{"id":"MzhRrpCb_Pv_","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598167309850,"user_tz":-330,"elapsed":1653,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"f252b919-f82f-46b1-eea4-2e9afdfc95fa"},"source":["# Q4- Create numpy array with 10 random no's from 0 to 10(one no should be greater than 1)?\n","rand_nums = np.random.randint(0,10,10)\n","rand_nums\n","\n","\n"],"execution_count":67,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([6, 9, 9, 8, 5, 9, 7, 7, 8, 0])"]},"metadata":{"tags":[]},"execution_count":67}]},{"cell_type":"code","metadata":{"id":"pVsKEC33Mdb4","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":102},"executionInfo":{"status":"ok","timestamp":1598167563507,"user_tz":-330,"elapsed":1126,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"b3558c06-c040-4534-fecf-7ff125067c22"},"source":["# Q5 - create a numpy array, convert it into 2d array with 5 rows and print it?\n","arr5 = np.array([1,2,3,4,5])\n","arr5.reshape(5,1)"],"execution_count":73,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[1],\n"," [2],\n"," [3],\n"," [4],\n"," [5]])"]},"metadata":{"tags":[]},"execution_count":73}]},{"cell_type":"code","metadata":{"id":"nd9j_Kn-Nbft","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598167717920,"user_tz":-330,"elapsed":1252,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"5b0305d7-96c0-4554-cf08-a7c73444247a"},"source":["# Q6- PRINT SHAPE OF THE ABOVE CURATED ARRAY?\n","arr5.shape"],"execution_count":75,"outputs":[{"output_type":"execute_result","data":{"text/plain":["(5,)"]},"metadata":{"tags":[]},"execution_count":75}]},{"cell_type":"code","metadata":{"id":"Eo4O4CYKOBKQ","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598168136620,"user_tz":-330,"elapsed":1006,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"83b52393-c81d-4956-f6ee-3ce4dd3aa6a5"},"source":["# Q7- Create a numpy array with 10 elements in it. Access the 3rd,4th,9th element?\n","arr6 = np.array([1,2,3,4,5,6,7,8,9,10])\n","print(arr6[2],arr6[3],arr6[8])\n"],"execution_count":83,"outputs":[{"output_type":"stream","text":["3 4 9\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"JlrBqemkPnb5","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598169267514,"user_tz":-330,"elapsed":1097,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"45f6a7eb-c7da-4d54-f5f1-c608051a54d2"},"source":["# Q8- Print alternate elements of above array?\n","print(arr6[0:2],arr6[4:8],arr6[9])\n","\n"],"execution_count":96,"outputs":[{"output_type":"stream","text":["[1 2] [5 6 7 8] 10\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"CLYrPZigT7g9","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":34},"executionInfo":{"status":"ok","timestamp":1598169477045,"user_tz":-330,"elapsed":1238,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"8b9639de-42c1-43cd-cb04-d86ed5e61fa6"},"source":["# Q9- Change the last 3 elements into 100?\n","arr6[7:len(arr6)] = 100\n","arr6"],"execution_count":98,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([ 1, 2, 3, 4, 5, 6, 7, 100, 100, 100])"]},"metadata":{"tags":[]},"execution_count":98}]},{"cell_type":"code","metadata":{"id":"Fl_fcTf0Uuoz","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":102},"executionInfo":{"status":"ok","timestamp":1598170147965,"user_tz":-330,"elapsed":1170,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"f34586ba-d754-4393-dd5e-6b2d5c8aa2d7"},"source":["# Q10- Create a 5x5 matrix ,print it. Then print the middle (3x3) matrix?\n","array = np.arange(25)\n","matrix5=array.reshape(5,5)\n","matrix5"],"execution_count":110,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[ 0, 1, 2, 3, 4],\n"," [ 5, 6, 7, 8, 9],\n"," [10, 11, 12, 13, 14],\n"," [15, 16, 17, 18, 19],\n"," [20, 21, 22, 23, 24]])"]},"metadata":{"tags":[]},"execution_count":110}]},{"cell_type":"code","metadata":{"id":"_og_4VffXSdG","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":68},"executionInfo":{"status":"ok","timestamp":1598170290702,"user_tz":-330,"elapsed":1534,"user":{"displayName":"VISHAL JENA","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14Gi3s4vwgm4-WxCI3Z00c46UXHGpRud4hAkH5mp_MA=s64","userId":"10167023063644792477"}},"outputId":"19bfb681-4bfe-431e-f989-2f90821f8301"},"source":["# now printing the middle (3x3) matrix\n","matrix5[1:4,1:4]"],"execution_count":111,"outputs":[{"output_type":"execute_result","data":{"text/plain":["array([[ 6, 7, 8],\n"," [11, 12, 13],\n"," [16, 17, 18]])"]},"metadata":{"tags":[]},"execution_count":111}]}]}
395 changes: 395 additions & 0 deletions Assignment1_Numpy.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,395 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Assignment1 Numpy.ipynb",
"provenance": [],
"authorship_tag": "ABX9TyPjJhiw9UZMcdcNfMiL21DQ",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/jenavishal/Python4DS/blob/master/Assignment1_Numpy.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "ig7-yF0L9ZYl",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "154c9eb2-3478-4fb9-b28d-a409e4c52c76"
},
"source": [
"# Q1 - create a list and convert into numpy and print it?\n",
"\n",
"import numpy as np\n",
"list = [1,2,3,4,5]\n",
"np.array(list)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([1, 2, 3, 4, 5])"
]
},
"metadata": {
"tags": []
},
"execution_count": 1
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "dDi5cIDU9-wF",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "e0baec02-57c4-4c54-f685-e6c3d4800f36"
},
"source": [
"# Q2- make a 3x3 matrix , convert in into numpy array and then print it?\n",
"matrix = [[1,2,3],[4,5,6],[7,8,9]]\n",
"np.array(matrix)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[1, 2, 3],\n",
" [4, 5, 6],\n",
" [7, 8, 9]])"
]
},
"metadata": {
"tags": []
},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "HcMkXlw6-v8T",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "7319facf-8b30-4969-f4c1-1e21db19ac32"
},
"source": [
"# Q3 - make a 3x3 matrix using arange,reshape?\n",
"arr = []\n",
"for i in range(1,18):\n",
" if(i%2!=0):\n",
" arr.append(i) # all i values is converted into list (name of list is arr)\n",
"arr2=np.array(arr) # arr2 list is converted into array\n",
"matrix1 = arr2.reshape(3,3)\n",
"matrix1\n",
"\n",
"\n",
"\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[ 1, 3, 5],\n",
" [ 7, 9, 11],\n",
" [13, 15, 17]])"
]
},
"metadata": {
"tags": []
},
"execution_count": 35
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "MzhRrpCb_Pv_",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "f252b919-f82f-46b1-eea4-2e9afdfc95fa"
},
"source": [
"# Q4- Create numpy array with 10 random no's from 0 to 10(one no should be greater than 1)?\n",
"rand_nums = np.random.randint(0,10,10)\n",
"rand_nums\n",
"\n",
"\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([6, 9, 9, 8, 5, 9, 7, 7, 8, 0])"
]
},
"metadata": {
"tags": []
},
"execution_count": 67
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "pVsKEC33Mdb4",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 102
},
"outputId": "b3558c06-c040-4534-fecf-7ff125067c22"
},
"source": [
"# Q5 - create a numpy array, convert it into 2d array with 5 rows and print it?\n",
"arr5 = np.array([1,2,3,4,5])\n",
"arr5.reshape(5,1)"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[1],\n",
" [2],\n",
" [3],\n",
" [4],\n",
" [5]])"
]
},
"metadata": {
"tags": []
},
"execution_count": 73
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "nd9j_Kn-Nbft",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "5b0305d7-96c0-4554-cf08-a7c73444247a"
},
"source": [
"# Q6- PRINT SHAPE OF THE ABOVE CURATED ARRAY?\n",
"arr5.shape"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(5,)"
]
},
"metadata": {
"tags": []
},
"execution_count": 75
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Eo4O4CYKOBKQ",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "83b52393-c81d-4956-f6ee-3ce4dd3aa6a5"
},
"source": [
"# Q7- Create a numpy array with 10 elements in it. Access the 3rd,4th,9th element?\n",
"arr6 = np.array([1,2,3,4,5,6,7,8,9,10])\n",
"print(arr6[2],arr6[3],arr6[8])\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"3 4 9\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "JlrBqemkPnb5",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "45f6a7eb-c7da-4d54-f5f1-c608051a54d2"
},
"source": [
"# Q8- Print alternate elements of above array?\n",
"print(arr6[0:2],arr6[4:8],arr6[9])\n",
"\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"[1 2] [5 6 7 8] 10\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "CLYrPZigT7g9",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "8b9639de-42c1-43cd-cb04-d86ed5e61fa6"
},
"source": [
"# Q9- Change the last 3 elements into 100?\n",
"arr6[7:len(arr6)] = 100\n",
"arr6"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([ 1, 2, 3, 4, 5, 6, 7, 100, 100, 100])"
]
},
"metadata": {
"tags": []
},
"execution_count": 98
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Fl_fcTf0Uuoz",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 102
},
"outputId": "f34586ba-d754-4393-dd5e-6b2d5c8aa2d7"
},
"source": [
"# Q10- Create a 5x5 matrix ,print it. Then print the middle (3x3) matrix?\n",
"array = np.arange(25)\n",
"matrix5=array.reshape(5,5)\n",
"matrix5"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[ 0, 1, 2, 3, 4],\n",
" [ 5, 6, 7, 8, 9],\n",
" [10, 11, 12, 13, 14],\n",
" [15, 16, 17, 18, 19],\n",
" [20, 21, 22, 23, 24]])"
]
},
"metadata": {
"tags": []
},
"execution_count": 110
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "_og_4VffXSdG",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "19bfb681-4bfe-431e-f989-2f90821f8301"
},
"source": [
"# now printing the middle (3x3) matrix\n",
"matrix5[1:4,1:4]"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[ 6, 7, 8],\n",
" [11, 12, 13],\n",
" [16, 17, 18]])"
]
},
"metadata": {
"tags": []
},
"execution_count": 111
}
]
}
]
}
Loading