Update records in dataset.
(self, records: pd.DataFrame)
| 63 | self.records = pd.concat([self.records, records], ignore_index=True) |
| 64 | |
| 65 | def update(self, records: pd.DataFrame): |
| 66 | """ |
| 67 | Update records in dataset. |
| 68 | """ |
| 69 | # Ignore if records is empty |
| 70 | if len(records) == 0: |
| 71 | return |
| 72 | |
| 73 | # Set 'id' as the index for both DataFrames |
| 74 | records.set_index('id', inplace=True) |
| 75 | self.records.set_index('id', inplace=True) |
| 76 | |
| 77 | # Update using 'id' as the key |
| 78 | self.records.update(records) |
| 79 | |
| 80 | # Remove null annotations |
| 81 | if len(self.records.loc[self.records["annotation"]=="Discarded"]) > 0: |
| 82 | discarded_annotation_records = self.records.loc[self.records["annotation"]=="Discarded"] |
| 83 | #TODO: direct `discarded_annotation_records` to another dataset to be used later for corner-cases |
| 84 | self.records = self.records.loc[self.records["annotation"]!="Discarded"] |
| 85 | |
| 86 | # Reset index |
| 87 | self.records.reset_index(inplace=True) |
| 88 | |
| 89 | def modify(self, index: int, record: dict): |
| 90 | """ |
no outgoing calls
no test coverage detected