Why do we create two separate empty lists to generate a 2D array?

In the code below, what is the reason for looping through to generate one list and then append one list to another list? Why not just use the first list that was generated?

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

converted_taxi_list = []
for row in taxi_list:
    converted_row = []
    for item in row:
        converted_row.append(float(item))
   
1 Like

@Willyjgolden: If you use just the first list, this would mean that the final output will be a 1D array, not 2D. In this case, we have a nested for loop, the inner loop to create each row and the outer loop to “stack” the rows together. Hope this clarifies!

1 Like