Skip to content

Searching a catalog for all but one value? #513

Answered by andersy005
r-ford asked this question in Q&A
Discussion options

You must be logged in to vote

thank you for your patience, @r-ford.

Is it possible to search a catalog to exclude a certain value instead of just manually listing all but one (something like source_id!='AWI-CM-1-1-MR')?

One way to do this is via a regular expression

In [35]: url
Out[35]: 'https://raw.githubusercontent.com/intake/intake-esm/main/tutorial-catalogs/GOOGLE-CMIP6.json'

In [36]: cat = intake.open_esm_datastore(url)


In [43]: cat.df.source_id.unique()
Out[43]: array(['IPSL-CM6A-LR', 'CanESM5'], dtype=object)
In [42]: cat.search(source_id='^((?!IPSL-CM6A-LR).)*$').df.source_id.unique()
Out[42]: array(['CanESM5'], dtype=object)

'^((?!IPSL-CM6A-LR).)*$' excludes all rows containing IPSL-CM6A-LR in source_id

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@r-ford
Comment options

Answer selected by r-ford
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants