climate_ref.cli._utils
#
df_to_table(df, max_col_count=-1)
#
Convert a DataFrame to a rich Table instance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame to convert |
required |
max_col_count
|
int
|
Maximum number of columns to display If the DataFrame has more columns than this, the excess columns will be truncated If set to -1, all columns will be displayed. For very wide DataFrames, then this may result in no values at all being displayed if the column-width ends up being less than 1 char. |
-1
|
Returns:
| Type | Description |
|---|---|
Rich Table instance representing the DataFrame
|
|
Source code in packages/climate-ref/src/climate_ref/cli/_utils.py
parse_facet_filters(filters)
#
Parse facet filters from key=value format into a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[str] | None
|
List of filter strings in 'key=value' format |
required |
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping facet keys to values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a filter string is not in valid 'key=value' format |
Examples:
>>> parse_facet_filters(["source_id=GFDL-ESM4", "variable_id=tas"])
{'source_id': 'GFDL-ESM4', 'variable_id': 'tas'}
Source code in packages/climate-ref/src/climate_ref/cli/_utils.py
pretty_print_df(df, console=None)
#
Pretty print a DataFrame
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame to print |
required |
console
|
Console | None
|
Console to use for printing If not provided, a new Console instance will be created |
None
|