vaexio / vaex

Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 🚀
https://vaex.io
MIT License
8.22k stars 589 forks source link

[BUG-REPORT] Vaex can't handle Enums being used to reference columns #2377

Open Ben-Epstein opened 1 year ago

Ben-Epstein commented 1 year ago

Description

import vaex
from enum import Enum, unique

@unique
class Col(str, Enum):
    id = "id"
    x = "x"

df = vaex.from_dict({
    Col.x: list(range(10)),
    Col.id: list(range(10, 20)),
})
df

ValueError: Unknown expression type: <class 'ast.Attribute'>

You need to do

df = vaex.from_dict({
    Col.x.value: list(range(10)),
    Col.id.value: list(range(10, 20)),
})

Which shouldn't be because we defined the class to inherit from str first.

Software information

Additional information Please state any supplementary information or provide additional context for the problem (e.g. screenshots, data, etc..).