Files
HowBadIsMyBatch/src/CompletedBatchcodeColumnAdder.py
2023-03-24 21:01:56 +01:00

13 lines
535 B
Python

import pandas as pd
class CompletedBatchcodeColumnAdder:
def __init__(self, completeBatchcode):
self.completeBatchcode = completeBatchcode
def addCompletedBatchcodeColumn(self, tableByPartialBatchcode):
partialBatchcodeTable = tableByPartialBatchcode.index.to_frame()
partialBatchcodeTable['Completed Batchcode'] = partialBatchcodeTable[tableByPartialBatchcode.index.name].map(self.completeBatchcode)
return tableByPartialBatchcode.set_index(pd.MultiIndex.from_frame(partialBatchcodeTable))