def addScheduleTree(self, FlatTree): length = len(self._nodes) if isinstance(FlatTree, str): FlatTree = StringIO(FlatTree) FlatTree = ResultTrees.ImTreeUtil.read_csv(FlatTree) self.FlatTree = self.FlatTree.append(FlatTree.iloc[1:]).reset_index(drop=True) it = FlatTree.iterrows() i = 0 data = ImNodeData(it.__next__()) # Throw Away root data = ImNodeData(it.__next__()) self.create_node(tag = str(data), identifier=length, data=data, parent=0) self.get_node(0).data.ExposureAmount += data.ExposureAmount self.get_node(0).tag=str(self.get_node(0).data) for row in it: data=ImNodeData(row) i += 1 node = Node(tag=str(data), identifier=i+length, data=data) parent_id = self.identify_parent_id(node) self.add_node(node, parent_id)
def __init__(self, FlatTree): self.hasEulerAllocation = False self.hasStandaloneAllocation = False #if it isn't a String it should be a pandas Dataframe if isinstance(FlatTree, str): FlatTree = StringIO(FlatTree) FlatTree = ResultTrees.ImTreeUtil.read_csv(FlatTree) self.FlatTree = FlatTree super(ImTree, self).__init__() it = FlatTree.iterrows() i = 0 data = ImNodeData(it.__next__()) self.create_node(tag=str(data), identifier=i, data=data) while i<(FlatTree.shape[0] - 1): i = i + 1 data = ImNodeData(it.__next__()) node = Node(tag=str(data), identifier=i, data=data) parent_id = self.identify_parent_id(node) self.create_node(tag = str(data), identifier=i, data=data, parent=parent_id)