Skip to content

Commit

Permalink
Merge pull request #5 from piidus/pandas
Browse files Browse the repository at this point in the history
Pandas
  • Loading branch information
piidus authored Jan 25, 2024
2 parents d649c3c + 72c5203 commit 5fa6ea0
Show file tree
Hide file tree
Showing 9 changed files with 7,458 additions and 0 deletions.
305 changes: 305 additions & 0 deletions 02-03-23_matplotlib.ipynb

Large diffs are not rendered by default.

541 changes: 541 additions & 0 deletions 23-02-23_pandas.ipynb

Large diffs are not rendered by default.

760 changes: 760 additions & 0 deletions 24-02-23_panda2.ipynb

Large diffs are not rendered by default.

1,013 changes: 1,013 additions & 0 deletions 25-02-23_panda.ipynb

Large diffs are not rendered by default.

360 changes: 360 additions & 0 deletions 26-2-23_numpy.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "82beff3b-d13e-4f35-9a4c-78d4f0e4eaa4",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"list_ = [ '1' , '2' , '3' , '4' , '5' ]\n",
"array_list = np.array(object = list_)"
]
},
{
"cell_type": "markdown",
"id": "8a48dca8-631c-4d18-bee2-724cc9b3bc57",
"metadata": {},
"source": [
"### Q1. Is there any difference in the data type of variables list_ and array_list? If there is then write a code to print the data types of both the variables."
]
},
{
"cell_type": "markdown",
"id": "b98a16f6-40a0-4cd9-88b7-a578c545b270",
"metadata": {},
"source": [
"> List_ is a python list object and\n",
"\n",
"> array_list is a numpy array."
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "d0e93297-1c9a-4905-b96b-149170ff8244",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'list'>\n",
"<class 'numpy.ndarray'>\n"
]
}
],
"source": [
"print(type(list_))\n",
"print(type(array_list))"
]
},
{
"cell_type": "markdown",
"id": "89d9edb9-46e6-4167-9a7f-00ab91d02a1b",
"metadata": {},
"source": [
"-------------"
]
},
{
"cell_type": "markdown",
"id": "aaabc819-c1f3-4604-86b3-70053fe406a9",
"metadata": {},
"source": [
"### Q2. Write a code to print the data type of each and every element of both the variables list_ and arra_list. "
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "ccb3047e-316c-44a2-8be4-ced0485ef8e9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[str, str, str, str, str]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# For List\n",
"l = [(type(i)) for i in list_]\n",
"l"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "9e553caf-e260-4b2d-b5b2-50800cf6d0ff",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[dtype('<U1'), dtype('<U1'), dtype('<U1'), dtype('<U1'), dtype('<U1')]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# For array_list\n",
"a = [ i.dtype for i in np.nditer(array_list)]\n",
"a"
]
},
{
"cell_type": "markdown",
"id": "81a653e9-ed4b-4613-8e41-07035b16c3cf",
"metadata": {},
"source": [
"--------------"
]
},
{
"cell_type": "markdown",
"id": "de20dd89-236c-4bd7-8855-4875cdede0a5",
"metadata": {},
"source": [
"### Q3. Considering the following changes in the variable, array_list:\n",
"\n",
" array_list = np.array(object = list_, dtype = int)\n",
"Will there be any difference in the data type of the elements present in both the variables, list_ and\n",
"arra_list? If so then print the data types of each and every element present in both the variables, list_\n",
"and arra_list."
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "c152f979-d66f-4726-8143-187b9117de39",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 2, 3, 4, 5])"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"array_list = np.array(object = list_, dtype = int)\n",
"array_list"
]
},
{
"cell_type": "markdown",
"id": "7fa0b900-56cd-4491-af1b-443700b644c7",
"metadata": {},
"source": [
">> array_list is numpy object which values are converted in Integer Format"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "09d903c1-40a4-4f78-ba15-6498d7a42f81",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"list Type : [<class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>, <class 'str'>] \n",
"array_list : [dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64')]\n"
]
}
],
"source": [
"# For List\n",
"l = [(type(i)) for i in list_]\n",
"al = [ i.dtype for i in np.nditer(array_list)]\n",
"print('list Type :', l, '\\n' 'array_list :', al)"
]
},
{
"cell_type": "markdown",
"id": "3d648e86-3c58-41d9-9648-de9f5050203e",
"metadata": {},
"source": [
"---------------"
]
},
{
"cell_type": "markdown",
"id": "e518bbd7-d11a-48a7-bfed-ece49db526d3",
"metadata": {},
"source": [
"### Q4. Write a code to find the following characteristics of variable, num_array:\n",
" -(i) shape\n",
" -(ii) size"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "634bb1b0-4cfb-425f-96cd-dba54de965fd",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"num_list = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ]\n",
"num_array = np.array(object = num_list)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "9f99f94a-91fe-4f28-8fa5-fdd55f02d1cb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"for Shape : (2, 3) \n",
"for Size : 6\n"
]
}
],
"source": [
"print('for Shape :', num_array.shape, '\\n''for Size :', num_array.size)"
]
},
{
"cell_type": "markdown",
"id": "55530fb1-a44b-47bd-a36c-fe0371cc5f8b",
"metadata": {},
"source": [
"_______"
]
},
{
"cell_type": "markdown",
"id": "9f33c8d6-92f7-4da1-b25a-6e1aec76497c",
"metadata": {},
"source": [
"### Q5. Write a code to create numpy array of 3*3 matrix containing zeros only, using a numpy array creation function.\n",
"[Hint: The size of the array will be 9 and the shape will be (3,3).]"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "d90e395a-dbcb-4030-bc2b-56dce122edd3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[0., 0., 0.],\n",
" [0., 0., 0.]])"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy.matlib as nm\n",
"nm.zeros((2,3))"
]
},
{
"cell_type": "markdown",
"id": "87c05630-7bfb-4678-99ea-a85109945632",
"metadata": {},
"source": [
"_______"
]
},
{
"cell_type": "markdown",
"id": "ce5f26f6-21ed-4093-aba6-4f13cad2979a",
"metadata": {},
"source": [
"### Q6. Create an identity matrix of shape (5,5) using numpy functions?\n",
"[Hint: An identity matrix is a matrix containing 1 diagonally and other elements will be 0.]"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "34bc61d8-3157-4be7-b7a6-095c2936857e",
"metadata": {},
"outputs": [],
"source": [
"ar = nm.eye(5)"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "5927ab62-b13f-4568-91a5-682471afa83e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[1., 0., 0., 0., 0.],\n",
" [0., 1., 0., 0., 0.],\n",
" [0., 0., 1., 0., 0.],\n",
" [0., 0., 0., 1., 0.],\n",
" [0., 0., 0., 0., 1.]])"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ar"
]
},
{
"cell_type": "markdown",
"id": "93a0779c-9959-44a5-a50f-e425b332107c",
"metadata": {},
"source": [
"___________"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 5fa6ea0

Please sign in to comment.