How to fix cfgrib TypeError: open_dataset() got an unexpected keyword argument 'filter_by_keys'
Problem:
You want to open a GRB2 file using the cfgrib library using code like
example-3.py
ds = xr.open_dataset('myfile.grb2', engine='cfgrib', filter_by_keys={'typeOfLevel': 'atmosphere'})But you see an exception like
example-2.txt
Solution
You can’t use filter_by_keys=… as argument to xr.open_dataset() directly. You need to use backend_kwargs like this:
example-1.txt
Check out similar posts by category:
Data Science, Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow