The real taxi tensor
From 6,433 real New York taxi trips, build a genuine order-3 tensor: pickup borough × dropoff borough × hour of day.
taxis['hour'] = pd.to_datetime(taxis['pickup']).dt.hour
T = np.zeros((len(pb), len(db), 24))
for (p, d, h), v in sub.groupby(['pickup_borough','dropoff_borough','hour']).size().items():
T[pb.index(p), db.index(d), h] = v
Entry T[i, j, k] is how many trips went from borough i to borough j during hour k. A flat table of 6,433 rows has become a tensor whose three axes each mean something different — which is exactly the situation PCA cannot handle.