query#
- Catalog.query(expr: str) Catalog[source]#
Filters catalog and respective margin, if it exists, using a complex query expression
- Parameters:
- exprstr
Query expression to evaluate. The column names that are not valid Python variables names should be wrapped in backticks, and any variable values can be injected using f-strings. The use of ‘@’ to reference variables is not supported. More information about pandas query strings is available here.
- Returns:
- Catalog
A catalog that contains the data from the original catalog that complies with the query expression. If a margin exists, it is filtered according to the same query expression.
Examples
Filter a small synthetic catalog using a pandas-style query string:
>>> import lsdb >>> from lsdb.nested.datasets import generate_data >>> nf = generate_data(1000, 5, seed=0, ra_range=(0.0, 300.0), dec_range=(-50.0, 50.0)) >>> catalog = lsdb.from_dataframe(nf.compute()[["ra", "dec", "id"]]) >>> filtered = catalog.query("ra < 100 and dec > 0") >>> filtered.head() ra dec id _healpix_29 118362963675428450 52.696686 39.675892 8154 98504457942331510 89.913567 46.147079 3437 70433374600953220 40.528952 35.350965 8214 154968715224527848 17.57041 29.8936 9853 67780378363846894 45.08384 31.95611 8297