OnSSET / onsset

The code of the Open Source Spatial Electrification Tool (OnSSET)
http://www.onsset.org
Other
26 stars 32 forks source link

Use multi-index including `year` rather than column string munging #73

Open willu47 opened 4 years ago

willu47 commented 4 years ago

At present, years in the analysis are represented by separate columns with the year integer in string for e.g. MyVariableName2015, or MyVariableName2030.

This then requires a lot of string formatting operations to index the year data, which is probably quite slow.

https://github.com/OnSSET/onsset/blob/0e0cf945fdb5267fdd5dbbbb3541d5c31b2b7dc5/onsset/onsset.py#L1722-L1728

It would be better to include a year column, so that every row is associated with a particular year, and then use a multi-index, or to use separate dataframes, one for each year.

willu47 commented 4 years ago

I think it would be better to use separate DataFrames, one for each year. This would make it a lot easier to add and remove years to and from the analysis, without changing the format of the output data (e.g. adding columns with years in the name).