import numpy as np
import numpy as np
vector = np.arange(5)
vector
matrix = np.arange(9).reshape(3, 3)
matrix
tensor = np.arange(12).reshape(3, 2, 2)
tensor
my_first_vector = np.array([2, 5, 6, 23])
print(my_first_vector)
my_first_matrix = np.array([[2, 4,], [6, 8]])
print(my_first_matrix)
my_list = [0, 1, 2, 3, 4]
print(np.array(my_list))
print(np.arange(start=2, stop=10, step=2))
print(np.arange(11, 1, -2))
print(np.linspace(start=11, stop=12, num=18))
print(np.linspace(0, 1, 11))
print(np.zeros(4))
print(np.zeros((2, 2)))
print(np.ones(6))
print(np.full(shape=(2, 2), fill_value=5))
print(np.full((2, 3, 4), 0.55))
base = np.linspace(2, 6, 4)
print(np.full_like(base, np.pi))
import matplotlib.pyplot as plt
uniform = np.random.uniform(0, 10, 10000)
normal = np.random.normal(0, 3, 10000)
plt.figure(figsize=(12,5))
plt.subplot(1, 2, 1)
plt.hist(uniform, bins=50)
plt.title('Distribución uniforme')
plt.subplot(1, 2, 2)
plt.hist(normal, bins=50)
plt.title('Distribución normal')
plt.show()
print(np.random.rand(2, 2))
rand = np.random.rand(10000)
plt.hist(rand, bins=50)
plt.show()
print(np.random.uniform(low=0, high=1, size=6))
uniform = np.random.uniform(low=0, high=1, size=10000)
plt.hist(uniform, bins=50)
plt.show()
print(np.random.randn(2, 2))
normal = np.random.randn(10000)
plt.hist(normal, bins=50)
plt.show()
print(np.random.normal(loc=0, scale=2, size=6))
normal2 = np.random.normal(0, 1, 10000)
plt.hist(normal2, bins=50)
plt.show()
print(np.random.randint(low=0, high=10, size=(3, 3)))
print(np.random.randint(1,100,10))
a = np.arange(1,10)
B = np.reshape(a, [3,3])
print(B)
C = np.arange(1, 9).reshape(2, 2, 2)
print(C)
print(B.shape)
print(B.dtype)
matrix_cool = np.arange(9).reshape(3, 3)
print(matrix_cool)
print(matrix_cool[1, 2])
print(matrix_cool[0, :])
print(matrix_cool[:, 1])
print(matrix_cool[:, 1:])
print(matrix_cool[0:2, 0:2])
print(matrix_cool[:, :])
a1 = np.array([2, 4, 6])
a2 = a1
a1[0] = 8
print(a1)
print(a2)
a1 = np.array([2, 4, 6])
a2 = a1.copy()
a1[0] = 8
print(a1)
print(a2)
# Suma
A = np.arange(5, 11)
print(A)
print(A + 10)
# Resta
B = np.full(4, 3)
C = np.ones(4, dtype='int')
print(B)
print(C)
print(B - C)
# Multiplicación y división
print(A * 10)
print(A / 10)
height_list = [74, 74, 72, 72, 73, 69, 69, 71, 76, 71, 73, 73, 74, 74, 69, 70, 73, 75, 78, 79, 76, 74, 76, 72, 71, 75]
print(np.mean(height_list))
print(np.median(height_list))
print(np.std(height_list))
print(np.max(height_list))
print(np.min(height_list))
import pandas as pd
df = pd.read_csv('Baseball_Players.csv')
height = df['Height(inches)'].to_numpy(dtype='int64')
weight = df['Weight(pounds)'].to_numpy(dtype='int64')
print(height)
height.shape
print(weight)
weight.shape
# Hora de resolver los ejercicios