import numpy as np

# a = np.array([4, 10, 12, 23, -2, -1, 0, 0, 0, -6, 3, -7])

# # How many negative numbers are there?
# negative_number = a < 0
# print(negative_number)
# print(sum(negative_number))

# # How many positive numbers are there?
# positive_number = a > 0
# print(positive_number)
# print(sum(positive_number))

# # How many even positive numbers are there?
# positive_numbers = a[a > 0]
# even_positive_numbers = positive_numbers % 2 == 0
# print(sum(even_positive_numbers))

# # If you were to add 3 to each data point, how many positive numbers would there be?
# b = a + 3
# print(b)
# tf_pos_b = b > 0
# print(tf_pos_b.sum())

# # If you squared each number, what would the new mean and standard deviation be?
# c = a ** 2
# print(c)
# print(np.mean(c))
# print(np.std(c))

# # A common statistical operation on a dataset is centering.
# # This means to adjust the data such that the center of the data is at 0.
# # This is done by subtracting the mean from each data point. Center the data set.
# centered_a = a - np.mean(a)
# print(centered_a)

# # Calculate the z-score for each data point. Recall that the z-score is given by:
# #               z = (x bar minus mu)/sigma
# z_scored = centered_a/np.std(a)
# print(z_scored)

# # Copy the setup and exercise directions from More Numpy Practice into your 4.7_numpy_exercises.py and add your solutions.
# # Life w/o numpy to life with numpy

# # Setup 1
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# # Use python's built in functionality/operators to determine the following:
# # Exercise 1 - Make a variable called sum_of_a to hold the sum of all the numbers in the above list
# sum_of_a = sum(a)
# print(sum_of_a)

# # Exercise 2 - Make a variable named min_of_a to hold the minimum of all the numbers in the above list
# min_of_a = min(a)
# print(min_of_a)

# # Exercise 3 - Make a variable named max_of_a to hold the max number of all the numbers in the above list
# max_of_a = max(a)
# print(max_of_a)

# # Exercise 4 - Make a variable named mean_of_a to hold the average of all the numbers in the above list
# mean_of_a = sum_of_a/len(a)
# print(mean_of_a)

# # Exercise 5 - Make a variable named product_of_a to hold the product of multiplying all the numbers in the above list together
# product_of_a = 1
# for i in a:
#     product_of_a = product_of_a * i
# print(product_of_a)

# # Exercise 6 - Make a variable named squares_of_a. It should hold each number in a squared like [1, 4, 9, 16, 25...]
# squares_of_a = [i ** 2 for i in a]
# print(squares_of_a)

# # Exercise 7 - Make a variable named odds_in_a. It should hold only the odd numbers
# odds_in_a = [i for i in a if i % 2 == 1]
# print(odds_in_a)

# # Exercise 8 - Make a variable named evens_in_a. It should hold only the evens.
# evens_in_a = [i for i in a if i % 2 == 0]
# print(evens_in_a)

# # What about life in two dimensions? A list of lists is matrix, a table, a spreadsheet, a chessboard...
# # Setup 2: Consider what it would take to find the sum, min, max, average, sum, product,
# # and list of squares for this list of two lists.
# b = np.array([
#     [3, 4, 5],
#     [6, 7, 8]
# ])
# print(b)

# # Exercise 1 - refactor the following to use numpy. Use sum_of_b as the variable. 
# # **Hint, you'll first need to make sure that the "b" variable is a numpy array**
# sum_of_b = np.sum(b)
# print(sum_of_b)

# # Exercise 2 - refactor the following to use numpy. 
# min_of_b = np.min(b)
# print(min_of_b)

# # Exercise 3 - refactor the following maximum calculation to find the answer with numpy.
# max_of_b = np.max(b)
# print(max_of_b)

# # Exercise 4 - refactor the following using numpy to find the mean of b
# mean_of_b = np.mean(b)
# print(mean_of_b)

# # Exercise 5 - refactor the following to use numpy for calculating the product of all numbers multiplied together.
# product_of_b = np.prod(b)
# print(product_of_b)

# # Exercise 6 - refactor the following to use numpy to find the list of squares 
# squares_of_b = b ** 2
# print(squares_of_b)

# # Exercise 7 - refactor using numpy to determine the odds_in_b
# odds_in_b = b[b % 2 == 1]
# print(odds_in_b)

# # Exercise 8 - refactor the following to use numpy to filter only the even numbers
# evens_in_b = b[b % 2 == 0]
# print(evens_in_b)

# # Exercise 9 - print out the shape of the array b.
# print(np.shape(b))

# # Exercise 10 - transpose the array b.
# print(np.transpose(b))

# # Exercise 11 - reshape the array b to be a single list of 6 numbers. (1 x 6)
# print(np.reshape(b, (6, )))

# # Exercise 12 - reshape the array b to be a list of 6 lists, each containing only 1 number (6 x 1)
# print(np.reshape(b, (6, 1)))

# # Setup 3
# c = np.array([
#     [1, 2, 3],
#     [4, 5, 6],
#     [7, 8, 9]
# ])
# print(c)

# # HINT, you'll first need to make sure that the "c" variable is a numpy array prior to using numpy array methods.
# # Exercise 1 - Find the min, max, sum, and product of c.
# print(np.min(c))
# print(np.max(c))
# print(np.sum(c))
# print(np.product(c))

# # Exercise 2 - Determine the standard deviation of c.
# print(np.std(c))

# # Exercise 3 - Determine the variance of c.
# print(np.var(c))

# # Exercise 4 - Print out the shape of the array c
# print(np.shape(c))

# # Exercise 5 - Transpose c and print out transposed result.
# print(np.transpose(c))
# c2 = np.transpose(c)

# # Exercise 6 - Multiply c by the c-Transposed and print the result.
# print(c * np.transpose(c))
# z = c * c2

# # Exercise 7 - Write the code necessary to sum up the result of c times c transposed. Answer should be 261
# print(np.sum(z))

# # Exercise 8 - Write the code necessary to determine the product of c times c transposed. Answer should be 131681894400.
# print(np.prod(z))


# # Setup 4
d = np.array([
    [90, 30, 45, 0, 120, 180],
    [45, -90, -30, 270, 90, 0],
    [60, 45, -45, 90, -45, 180]
])
# print(d)

# # Exercise 1 - Find the sine of all the numbers in d
# print(np.sin(d))

# # Exercise 2 - Find the cosine of all the numbers in d
# print(np.cos(d))

# # Exercise 3 - Find the tangent of all the numbers in d
# print(np.tan(d))

# # Exercise 4 - Find all the negative numbers in d
# print(d[d < 0])

# # Exercise 5 - Find all the positive numbers in d
# print(d[d > 0])

# # Exercise 6 - Return an array of only the unique numbers in d.
# print(np.unique(d))

# # Exercise 7 - Determine how many unique numbers there are in d.
# print(len(np.unique(d)))

# # Exercise 8 - Print out the shape of d.
# print(np.shape(d))

# Exercise 9 - Transpose and then print out the shape of d.
print(d.T.shape)

# Exercise 10 - Reshape d into an array of 9 x 2
print(np.reshape(d, (9, 2)))