read/write extra (meta) columns
goal: read/write extra (meta) columns without necessarily knowing their names.
Closes #108 (closed)
Merge request reports
Activity
added internal architecture + 1 deleted label
281 281 raise ValueError(f"key(s) missing in flags: {failed}") 282 282 return field 283 283 284 def getExtraCols(self, field, loc=None): I think, I prefer to implement this functionality into
getFlags
. This could be realized, for example, through an additional keyword, let's call itall=False
. So per defaultgetFlags
would return a Series and withall=True
a dictionary, that at least contains one item (e.g.{"flags": data_series}
. In case of theDmpFlagger
the return value could be something like{"flags": data_series, "comments": comments_series, "causes": causes_series}
.This would prevent a further bloat of the
flagger
-interface and, more importantly, would allow a unified handling of the return values. In case ofgetExtraCols
, the returned dict is potentially empty and we always need to check for validity before we can use it. Especially this would break:flagger = BaseFlagger(data) flagger.setFlagsWithExtracCols(field, loc, **flagger.getExtraCols(field, loc))
If implement like proposed above, this would instead always work (and could even be the default internal usage):
flagger = BaseFlagger(data) flagger.setFlags(field, loc, **flagger.getFlags(field, loc, all=True))
changed this line in version 4 of the diff
297 dict 298 A dictionary holding the metadata. All items are pd.Series(), with an index equal to flags[loc,field] 299 and all keys are known kwargs to `setFlagsWithExtraCols()`. 300 301 See Also 302 -------- 303 setFlagsWithExtraCols : counterpart to this method to write extra columns. 304 305 Examples 306 -------- 307 See `flagger.setFlagsWithExtraCols()` for an example. 308 """ 309 assertScalar("field", self._check_field(field), optional=False) 310 return dict() 311 312 def setFlagsWithExtraCols(self, field, loc=None, flags=None, inplace=False, **kwargs): changed this line in version 3 of the diff
removed internal architecture label
added 3 commits
mentioned in commit c3159d8b