From 973d38072a5481c19985d1ad5c15edffca61bcf1 Mon Sep 17 00:00:00 2001 From: Bernardo Porto Veronese Date: Mon, 22 Jul 2024 15:12:51 -0300 Subject: [PATCH] Update readme --- README.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 860901e..176cec1 100644 --- a/README.md +++ b/README.md @@ -9,23 +9,45 @@ Parser for the [GLADE+ galaxy catalog](https://glade.elte.hu/). To read the catalog into a `pandas.DataFrame`: ```python -from gladeparser import to_df +from gladeparser import to_pandas_df filename = "path/to/catalog" -df = to_df(filename) +df = to_pandas_df(filename) +``` + +The preferred way of reading the catalog is using a `polars` backend, especially if you want to filter out the data: + +```python +from gladeparser import to_polars_df +import polars as pl + +# Grab objects from 2MASS catalog with redshifts corrected for peculiar velocity +filters = ( + pl.col("2MASS name").is_not_null(), + pl.col("z_cmb").is_not_null(), + pl.col("z_cmb") > 0, + pl.col("z flag") == 1, + pl.col("dist flag").is_in([1, 3]) +) + +# Selected columns +cols = ["ra", "dec", "z_cmb"] + +filename = "path/to/catalog" +df = to_polars_df(filename, cols=cols, **filters) ``` ### Parsing a subset of columns ```python -from gladeparser import to_df, get_columns +from gladeparser import to_pandas_df, get_columns # Select the columns you want and return their names # See more options in get_columns docstring cols = get_columns('Localization', 'Distance', names=True) filename = "path/to/catalog" -df = to_df(filename, cols=cols) +df = to_pandas_df(filename, cols=cols) ``` ## Installation