Skip to content

generalize set_labels to support group keys #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gdementen opened this issue Dec 23, 2020 · 2 comments
Open

generalize set_labels to support group keys #906

gdementen opened this issue Dec 23, 2020 · 2 comments

Comments

@gdementen
Copy link
Contributor

gdementen commented Dec 23, 2020

As hinted in #361 and a follow-up to #634, it would often be useful to support group keys in set_labels:

>>> arr = ndtest(10)
>>> arr
a  a0  a1  a2  a3  a4  a5  a6  a7  a8  a9
    0   1   2   3   4   5   6   7   8   9
>>> arr.set_labels({'a1,a3,a4': 'a134', 'a6,a8': 'a68'})
a  a0  a134  a2  a134  a134  a5  a68  a7  a68  a9
    0     1   2     3     4   5    6   7    8   9

>>> arr = ndtest("a=01..10").with_total()
>>> arr
a  01  02  03  04  05  06  07  08  09  10  total
    0   1   2   3   4   5   6   7   8   9     45
>>> arr.set_labels({'01..10': int})
a  1  2  3  4  5  6  7  8  9  10  total
   0  1  2  3  4  5  6  7  8   9     45
@gdementen gdementen self-assigned this Aug 6, 2021
@gdementen gdementen added this to the 0.34 milestone Aug 6, 2021
@gdementen
Copy link
Contributor Author

The last example will need the "apply a function to labels" feature to work for groups in AxisCollection.set_labels, which would benefit from merging Axis.set_labels and Axis.apply (see #783)

gdementen added a commit to gdementen/larray that referenced this issue Oct 11, 2021
…s" as labels

array.set_labels({'a0:a1': 'A0..A1'}) (closes larray-project#906)
@gdementen gdementen modified the milestones: 0.34, 0.35 Sep 29, 2022
@gdementen
Copy link
Contributor Author

moved to milestone 0.35 because I want to make sure the syntax is consistent with #905 and #455 etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant