How can I use python methods to split up the data drame with respect to weekday and hour?

Viewed 22

I have a dataset, I have split up the time into weekdays and hour here (first table). I have to count the number of trips(demand) strating from PULocationID to DOLocationID for every hour for every day. I did this by groupping and using the size method(table 2). I have also sorted(ascending) these entries with respect to time before I do this. How can I use the default pyhon methods from numpy and pandas(so that I can still use this method to scale up for more data) to generate a 2D feature map for every hour and for all weekdays and fill in the demand(trip count)?

The code snippet and dataframe information

Additonal information: There are 265 PULocationIDs, 265 DOLocationIDs. So the 2D map should be a (265,265) a matrix(np array or df) for an hour in one week day filled by demand values. for ex. if the first map is the demand at 8 AM, second map should be demand at 9 AM and so on after 23 it should strat the next day. Any help or suggestions would be greatly appreciated.

Thank you!

0 Answers
Related