fitsmgmt.table.df_selector
fitsmgmt.table.df_selector(
summarytab,
fullmatch=None,
flags=0,
negate_fullmatch=False,
querystr=None,
columns=None,
columns_drop=None,
reset_index=True,
copy=True,
)Select rows from a summary table.
Parameters
summarytab :~pandas.DataFrame-
The summary table to select from. Normally the table made from header information.
fullmatch :dict= None-
The
{column: regex}styledictto be used for selecting rows bysummarytab[column].str.fullmatch(regex, case=True). An example:{"OBJECT": "Ves.*"}. All corresponding columns must have dtype ofstrto apply regex. Default:None negate_fullmatch : bool = False-
Whether to negate the mask by
fullmatch, in case the user does not want to think much about regex to negate it. Default:False. flags : int = 0-
Regex module flags, e.g. re.IGNORECASE. Default: 0
querystr :str= None-
The query string used for
summarytab.query(querystr). See~pandas.DataFrame.query. columns : str | list[str] | None = None-
The
listof columns to be returned/dropped after selection. No need to setup both, but no Error will be raised even the user does so. Default:None. columns_drop : str | list[str] | None = None-
The
listof columns to be returned/dropped after selection. No need to setup both, but no Error will be raised even the user does so. Default:None. reset_index :bool, optional. = True-
Whether to reset the DataFrame index after selection. Default:
True. copy :bool, optional. = True-
Whether to copy the input table before selection. Default:
True.
Returns
: summarytab-
The final summary table after selection. If everything is
None(the default), the original summary table is returned.
Raises
: AttributeError-
The column dtype is not
str : TypeError-
fullmatch must be in
dict.
Examples
Select all rows with OBJECT starts with “DA”:
>>> # fullmatch = {"OBJECT": "DA.*"}
Select all rows with ``OBJECT`` starts with "Ves", ``FILTER`` is "J", and
``EXPTIME`` is 2 or 3:>>> # fullmatch = {"OBJECT": "Ves.*", "FILTER": "J"},
>>> # querystr="EXPTIME in [2, 3]"