adding MultiIndexExploderTest

This commit is contained in:
frankknoll
2023-02-14 16:51:22 +01:00
parent 0ae6e56f33
commit 151aa9cd48
3 changed files with 63 additions and 0 deletions

12
src/MultiIndexExploder.py Normal file
View File

@@ -0,0 +1,12 @@
import numpy as np
import Utils
class MultiIndexExploder:
@staticmethod
def explodeMultiIndexOfTable(table):
batchcodeColumns = table.index.names
explodedTable = table.loc[np.repeat(table.index, len(batchcodeColumns))].reset_index()
explodedTable['VAX_LOT_EXPLODED'] = Utils.flatten(table.index.values)
return explodedTable.set_index(['VAX_LOT_EXPLODED'] + batchcodeColumns)