obsplus.DataFrameExtractor¶
- class obsplus.DataFrameExtractor(cls, required_columns=None, dtypes=None, pass_dataframe=True, column_funcs=None)[source]¶
A class to extract dataframes from nested object trees.
Generally used to construct summary dataframes from nested object structures such as the obspy Catalog.
- Parameters:
cls – The top-level class the extractor acts on.
required_columns (
Optional
[Sequence
[str
]]) – If not None, assert required columns are in dataframe, and order columns the same as required_columns, with extra columns at the end.dtypes – A dict of {column name: required data type}. Can also be specified when registering extractors.
pass_dataframe – If True, return dataframes passed to DataFrameExtractor.__call__. This allows the DataFrameExtractor to be idempotent.
column_funcs (
Optional
[Mapping
[str
,Callable
[[Series
],Union
[Series
,ndarray
]]]]) – Columns that are UTCDateTime objects. Will correctly handle UTCDateTime-able objects (like date-time strings, floats, etc).
Methods
__init__
(cls[, required_columns, dtypes, ...])clear
()copy
()Return a deep copy of the fetcher.
extractor
([dtypes])Register an extractor.
fromkeys
(iterable[, value])get
(k[,d])items
()keys
()pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
()as a 2-tuple; but raise KeyError if D is empty.
register
(cls)Registers an alternate constructor.
setdefault
(k[,d])update
([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
()Attributes
dtypes
return a dictionary of datatypes.
nslc