altair-viz / altair-transform

Evaluation of Vega-Lite transforms in Python
MIT License
70 stars 8 forks source link

transform_chart breaks with BinParams extent #58

Open indigoviolet opened 2 years ago

indigoviolet commented 2 years ago
from altair_transform import transform_chart
transform_chart(
    alt.Chart(cdf2.select(pr.col("cleaned_stat_len")).to_pandas().head(100))
    .mark_bar()
    .encode(
        x=alt.X("binned_len:O"),
        y=alt.Y("count()", scale=alt.Scale(type="log")),
        tooltip="count()",
    ).transform_bin(
        'binned_len', field='cleaned_stat_len', bin=alt.Bin(maxbins=50, extent=[0, 100]) 
    )
)

Truncated Traceback (Use C-c C-$ to view full TB):
File ~/dev/instant-science/trademark/.venv/lib/python3.9/site-packages/altair_transform/transform/bin.py:36, in visit_bin(transform, df)
     33 field = transform_dct["field"]
     34 extent = df[field].min(), df[field].max()
---> 36 bins = calculate_bins(extent, **({} if bin is True else bin))
     38 if isinstance(col, str):
     39     df[col] = _cut(df[field], bins, return_upper=False)

TypeError: calculate_bins() got multiple values for argument 'extent'