Thursday, November 14, 2019

Learning Datascience Day 1

After Learning Python( Day 1-Day 10)
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-1.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-2.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-3.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-4.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-5.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-6.html
https://technologyandarchitecture.blogspot.com/2019/10/learning-python-day-7.html
https://technologyandarchitecture.blogspot.com/2019/11/learning-python-day-8.html
https://technologyandarchitecture.blogspot.com/2019/11/learning-python-day-9.html
https://technologyandarchitecture.blogspot.com/2019/11/learning-python-day-10.html


DATASCIENCE

DAY1
We will use Jupiter notebook. Please check prerequisites of installing jupyter notebook
Today we will start with Numpy module
Remember we need to import number for each notebook
import numpy as np
in above np can be anything even your name, consider as a synonym or shortform for numpy
arr1=np.array([11,22,33,44])
arr1
array([11, 22, 33, 44])

Note: Array is like a list
If we want to make 2 dimensional array
arr2=np.array([[1,2,3],[4,5,6],[7,8,9]])
print(arr2)
[[1 2 3]
 [4 5 6]
 [7 8 9]]
 
Arrange creates an array within a range, se below example
arr3=np.arange(2,10)
arr3
array([2, 3, 4, 5, 6, 7, 8, 9])
 
arr4=np.arange(2,10,2)
arr4
array([2, 4, 6, 8])
 
 
now with zeroes function
arr5=np.zeros((2,3))
arr5
array([[0., 0., 0.],
       [0., 0., 0.]])
 
If we look above example the output is 0. Means it’s a float and if we want to convert float to integer
 
arr6=np.zeros((3,3),dtype=np.int32)
arr6
array([[0, 0, 0],
       [0, 0, 0],
       [0, 0, 0]])
 
arr7=np.ones((3,4))
arr7
array([[1., 1., 1., 1.],
       [1., 1., 1., 1.],
       [1., 1., 1., 1.]])
 
arr9=np.empty((3,3))
arr9
array([[0.00000000e+000, 0.00000000e+000, 0.00000000e+000],
       [0.00000000e+000, 0.00000000e+000, 6.67976753e-321],
       [2.13622844e-306, 2.33419537e-312, 2.56765117e-312]])
 
To find the dimension of the array use the command ndim
arr1
array([11, 22, 33, 44])

arr2
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
print(arr1.ndim)
1
print(arr2.ndim)
2
To find the number of elements in the array use size function
print(arr1.size)
to find out item size( size of elements in bytes)
print(arr1.itemsize)
4
Similarly
print(arr1.dtype)
int32

print(arr9.dtype)
float64
print(arr1.shape)
(4,)


arr10=np.arange(1,13)
arr10
array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12])

now we will reshape arr10 from one dimensional to multi dimensional
arr10.reshape((4,3))
array([[ 1,  2,  3],
       [ 4,  5,  6],
       [ 7,  8,  9],
       [10, 11, 12]])


a=np.array([[1,2,3],[4,5,6], [7,8,9]])
a
a+a
array([[ 2,  4,  6],
       [ 8, 10, 12],
       [14, 16, 18]])

Similarly
a-a
a*a
a/a
a**a

b=np.array([[10,11,12,20],[13,14,15,30],[16,17,18,40]])
b
array([[10, 11, 12, 20],
       [13, 14, 15, 30],
       [16, 17, 18, 40]])

In the above example lets clear it up with detail explanation

0
1
2
3
0
10
11
12
20
1
13
14
15
30
2
16
17
18
40





When we run the command
B[1,2]
Output is 15
So how the output is 15, index 1 that’s row 1 and column 2, and that is 15
b[1]
array([13, 14, 15, 30])

b[0:2,1:4]
array([[11, 12, 20],
       [14, 15, 30]])
In the above example, rows will be 0 and 1 and column will be 1 to 3
c=np.arange(1,12)
c
array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11])

d=c[2:5]
d
now if we change the value of d at any index, then it also automatically changes the value of C also
d[1]=100
d
array([  3, 100,   5])

c
array([  1,   2,   3, 100,   5,   6,   7,   8,   9,  10,  11])

e=c[1:5].copy()
e

array([  2,   3, 100,   5])


Learning Datascience -Day2

No comments:

Post a Comment

Featured Post

Ichimoku cloud

Here how you read a ichimoku cloud 1) Blue Converse line: It measures short term trend. it also shows minor support or resistance. Its ve...