| 134 | plt.show() |
| 135 | |
| 136 | def pick_labeled_frame(self): |
| 137 | # Find the most 'complete' animal |
| 138 | if "individuals" in self.df.columns.names: |
| 139 | count = self.df.T.groupby(level="individuals").count().T |
| 140 | if "single" in count.columns: |
| 141 | count = count.drop(columns="single") |
| 142 | else: |
| 143 | count = self.df.count(axis=1).to_frame() |
| 144 | mask = count.where(count == count.to_numpy().max()) |
| 145 | kept = mask.stack().index.to_list() |
| 146 | np.random.shuffle(kept) |
| 147 | picked = kept.pop() |
| 148 | row = picked[:-1] |
| 149 | col = picked[-1] |
| 150 | return row, col |
| 151 | |
| 152 | def clear(self, *args): |
| 153 | self.inds.clear() |