October 2018
Beginner to intermediate
676 pages
18h 30m
English
Now let's read the same data from an .xlsx file and create the x and y NumPy arrays. The .xlsx file format is not supported by the NumPy loadtxt() function. A Python data processing package, pandas can be used:
df = pd.read_excel('test.xlsx', 'sheet', header=None)
data_array = np.array(df)print(data_array)
You should see the following output:
[[ 1 1] [ 2 4] [ 3 9] [ 4 16] [ 5 25]]
x , y = data_array[:,0], data_array[:,1]print(x,y)
You should see the following output:
[1 2 ...
Read now
Unlock full access