Transport-for-the-North / caf.toolkit

https://caftoolkit.readthedocs.io/en/stable/
Other
0 stars 1 forks source link

[API Change] Long and Wide Pandas Conversions #116

Open BenTaylor-TfN opened 5 months ago

BenTaylor-TfN commented 5 months ago

Current methods for converting pandas DataFrame between wide and long format do not use the index columns correctly. Instead, columns that would be the index are treated as any other column. It could be beneficial to convert these methods to use Index columns instead.

This change should result in less arguments needed for function calls, and slightly faster operation as more can be inferred (never mind the internal pandas speed gains). The following functions would be impacted:

If going ahead with this update we need to be careful how the API change is fed back into users. Internal changes should easily be flagged by test failures, but other CAF packages may need updating to take these changes into account.

isaac-tfn commented 5 months ago

On the third point, is this supposed to make a multiindex with every possible combination of index values from different levels? I've done the other three will push up now and link to this issue.

BenTaylor-TfN commented 5 months ago

On the third point, is this supposed to make a multiindex with every possible combination of index values from different levels?

That's right. There's some added functionality to make some assumptions where a defined list isn't given too.

isaac-tfn commented 5 months ago

On the third point, is this supposed to make a multiindex with every possible combination of index values from different levels?

That's right. There's some added functionality to make some assumptions where a defined list isn't given too.

OK I'll rewrite it now, having some trouble with black but hopefully have stuff pushed up by the end of the day