Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Porto Veronese committed Jul 22, 2024
1 parent 43a5498 commit 973d380
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 973d380

Please sign in to comment.