Introduction to NumPy Step 4 : dataquest platform VS JupyterLab

Screen Link:
https://app.dataquest.io/m/289/introduction-to-numpy/4/nyc-taxi-airport-data

I performed the same code on dataquest console and on my JupyterLab

My Code:

import csv
import numpy as np

# import nyc_taxi.csv as a list of lists
f = open("nyc_taxis.csv", "r")
taxi_list = list(csv.reader(f))

# remove the header row
taxi_list = taxi_list[1:]

# convert all values to floats
converted_taxi_list = []
for row in taxi_list:
    converted_row = []
    for item in row:
        converted_row.append(float(item))
    converted_taxi_list.append(converted_row)

# start writing your code below this comment
taxi = np.array(converted_taxi_list)

Dataquest console result :

array([[  2016,      1,      1, ...,  11.65,  69.99,      1],
       [  2016,      1,      1, ...,      8,   54.3,      1],
       [  2016,      1,      1, ...,      0,   37.8,      2],
       ...,
       [  2016,      6,     30, ...,      5,  63.34,      1],
       [  2016,      6,     30, ...,   8.95,  44.75,      1],
       [  2016,      6,     30, ...,      0,  54.84,      2]])

My JupyterLab result :

array([[2.016e+03, 1.000e+00, 1.000e+00, ..., 1.165e+01, 6.999e+01,
        1.000e+00],
       [2.016e+03, 1.000e+00, 1.000e+00, ..., 8.000e+00, 5.430e+01,
        1.000e+00],
       [2.016e+03, 1.000e+00, 1.000e+00, ..., 0.000e+00, 3.780e+01,
        2.000e+00],
       ...,
       [2.016e+03, 6.000e+00, 3.000e+01, ..., 5.000e+00, 6.334e+01,
        1.000e+00],
       [2.016e+03, 6.000e+00, 3.000e+01, ..., 8.950e+00, 4.475e+01,
        1.000e+00],
       [2.016e+03, 6.000e+00, 3.000e+01, ..., 0.000e+00, 5.484e+01,
        2.000e+00]])

Why ?

Many thanks

2 Likes

Set numpy print option set_printoptions

np.set_printoptions(suppress=True)

To turn off scientific notation of number.

suppress bool, optional

If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero. If False, then scientific notation is used when absolute value of the smallest number is < 1e-4 or the ratio of the maximum absolute value to the minimum is > 1e3. The default is False.
See more

1 Like

Thank you ! :slightly_smiling_face:
it worked

2 Likes