# Month: May 2018

## Analyzing Stock Data with Numpy – The Reshape and Average Functions

Daily Data Science Puzzle [python] import numpy as np # apple stock prices (May 2018) prices = [ 189, 186, 186, 188, 187, 188, 188, 186, 188, 188, 187, 186 ] prices = np.array(prices) data_3day = prices.reshape(4,3) print(int(np.average(data_3day[0]))) print(int(np.average(data_3day[-1]))) [/python] What is the output of this puzzle? Numpy is a popular Python library for data …

## How to Create a Sequence of Evenly Spaced Values with Numpy Linspace?

Daily Data Science Puzzle [python] import numpy as np year = np.linspace(0, 365, 366) print(int(year[-1] – year[-2])) [/python] What is the output of this puzzle? Numpy is a popular Python library for data science focusing on linear algebra. This puzzle is about the useful function linspace. In particular, linspace(start, stop, num) returns evenly spaced numbers …

## How to Create a Sequence of Linearly Increasing Values with Numpy Arange?

Daily Data Science Puzzle [python] import numpy as np # save \$122.50 per month x = 122.5 net_wealth = np.arange(0, 1000, x) # how long to save >\$1000? print(len(net_wealth)) [/python] What is the output of this puzzle? Numpy is a popular Python library for data science focusing on linear algebra. This puzzle is about the …