Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I've been meaning to share that I pulled out some code from cf-xarray to make cf-pandas: https://github.com/axiom-data-science/cf-pandas.

The goal is to be able to use the same syntax from cf-xarray but with pandas DataFrames when working with both models and tabular data. For example, I copied in the same criteria used for selecting latitude, longitude, and time and use them to match the column names in a DataFrame to be able to use e.g.:

df.cf["longitude"]

You can also use custom_criteria to be able to interpret variables by alias. A lot of the code in the package right now is in this effort due to what I've needed, included support classes for writing regular expressions and the custom criteria dictionaries though there I call them "vocab".

Please let me know if I should add anything to better link cf-pandas to cf-xarray or give better credit. I try to reference cf-xarray all over the place but I might have missed something important to say.

You must be logged in to vote

Replies: 1 comment · 2 replies

Comment options

kthyng
Feb 2, 2023
Maintainer Author

@dcherian Just wanted to have this out there so you are aware of it.

You must be logged in to vote
2 replies
@dcherian
Comment options

Wow this is quite cool. We should link to it from cf-xarray docs!

The Reg and Vocab classes look quite interesting. Are those popular with users? Perhaps we should break that out to a separate package and both cf-xarray and cf-pandas can use it.

@kthyng
Comment options

kthyng Feb 2, 2023
Maintainer Author

To be clear, I (and packages I am writing) am the only user at this point to my knowledge :) I find the classes really useful though! I also separated out the logic for the basic pattern-matching so it can occur for any input list of strings which I have used in several related contexts — since the approach for the pattern matching outside of standardized netcdf files is less specified.

I also brought over your always_iterable which I used regularly in a bunch of projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.