misken / hillmaker

Occupancy analysis by time of day and day of week, with Python
MIT License
6 stars 4 forks source link

Should we flatten multi-index of results dataframes? #57

Closed misken closed 1 year ago

misken commented 1 year ago

Right now, the summary dataframe has a multi-index:

day_of_week | dow_name | bin_of_day | bin_of_day_str |  

This makes it painful to select specific rows (e.g. Monday). If we flatten the index and stick the levels as regular columns, it will be much easier to select some subset of rows. In the plotting code, we flatten the index to make it easy to make the plot.

What do you think @jwnorm ?

jwnorm commented 1 year ago

In practice, one of the very first things I do when playing with the summary df is .reset_index(), so I think that this is a good quality of life improvement. I know for sure in the compute_operating_hours function, there is a line that resets the index of the df, so just one thing to keep in mind. Not sure if this impacts any plotting functionality as well.

misken commented 1 year ago

Thanks. Yes, I could think of no good reason to not flatten the index. I've already done it and will remove the redundant .reset_index commands in both plotting and compute_operating_hours.

misken commented 1 year ago

Removed the unnecessary .reset_index commands from both plotting and compute_operating_hours.