8000 implement Axis.astype · Issue #880 · larray-project/larray · GitHub
[go: up one dir, main page]

Skip to content
implement Axis.astype #880
Closed
Closed
@gdementen

Description

@gdementen

I relatively often need to change an axis labels dtype. For example to convert labels to int64, I currently have to do:

>>> arr = ndtest("a=1..3")
>>> arr.a.dtype
dtype('int32')
>>> arr.set_labels('a', arr.a.labels.astype(np.int64))
>>> # this would be a tad shorter and makes sense IMO
... arr.set_labels('a', arr.a.astype(np.int64))

In an ideal world, arr.set_labels('a', np.int64) would work too (but I am unsure it is possible). It currently returns an object array for the axis labels:

>>> arr.set_labels('a', np.int64).a.dtype
dtype('O')

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0