Introduction to Python for Finance
Adina Howe
Instructor
pip3 install package_name_here
pip3 install numpy
import numpy
import numpy
my_array = numpy.array([0, 1, 2, 3, 4])
print(my_array)
[0, 1, 2, 3, 4]
print(type(my_array))
<class 'numpy.ndarray'>
import package_name
package_name.function_name(...)
import numpy as np
my_array = np.array([0, 1, 2, 3, 4])
print(my_array)
[0, 1, 2, 3, 4]
my_array = np.array([3, 'is', True])
print(my_array)
['3' 'is' 'True']
my_list = [3, 'is', True]
print(my_list)
[3, 'is', True]
import numpy as np
array_A = np.array([1, 2, 3])
array_B = np.array([4, 5, 6])
print(array_A + array_B)
[5 7 9]
list_A = [1, 2, 3]
list_B = [4, 5, 6]
print(list_A + list_B)
[1, 2, 3, 4, 5, 6]
import numpy as np months_array = np.array(['Jan', 'Feb', 'March', 'Apr', 'May'])
print(months_array[3])
Apr
print(months_array[2:5])
['March' 'Apr' 'May']
import numpy as np
months_array = np.array(['Jan', 'Feb', 'March', 'Apr', 'May'])
print(months_array[0:5:2])
['Jan' 'March' 'May']
Introduction to Python for Finance