Skip to content
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

hvplot.hist with ibis+duckdb: ValueError: The truth value of an Ibis expression is not defined #996

Closed
MarcSkovMadsen opened this issue Nov 30, 2022 · 0 comments · Fixed by #997
Labels

Comments

@MarcSkovMadsen
Copy link
Collaborator

hvplot==0.8.1

I'm trying to contribute a guide for ibis + DuckDB. When I try to plot a hist plot I get ValueError: The truth value of an Ibis expression is not defined.

import duckdb
import ibis
import pandas as pd

from pathlib import Path
import hvplot.ibis
import holoviews as hv

hvplot.extension("plotly")

DUCKDB_PATH = "DuckDB.db"

if not Path(DUCKDB_PATH).exists():
    pandas_df = pd.DataFrame(
        {
            "actual": [100, 150, 125, 140, 145, 135, 123],
            "forecast": [90, 160, 125, 150, 141, 141, 120],
            "numerical": [1.1, 1.9, 3.2, 3.8, 4.3, 5.0, 5.5],
            "date": pd.date_range("2022-01-03", "2022-01-09"),
            "string": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
    )
    duckdb_con = duckdb.connect(DUCKDB_PATH)
    duckdb_con.execute("CREATE TABLE df AS SELECT * FROM pandas_df")

ibis.options.sql.default_limit = None

db = ibis.duckdb.connect(DUCKDB_PATH)

df = db.table("df")
df.hvplot.hist("forecast", bins=3)
C:\repos\private\hvplot\.venv\lib\site-packages\ibis\backends\postgres\registry.py:164: UserWarning: locale specific date formats (%c, %x, %X) are not yet implemented for Windows
  warnings.warn(
C:\repos\private\hvplot\.venv\lib\site-packages\duckdb_engine\__init__.py:229: DuckDBEngineWarning: duckdb-engine doesn't yet support 
reflection on indices
  warnings.warn(
Traceback (most recent call last):
  File "C:\repos\private\hvplot\script2.py", line 31, in <module>
    df.hvplot.hist("forecast", bins=3)
  File "C:\repos\private\hvplot\hvplot\plotting\core.py", line 1309, in hist
    return self(kind="hist", x=None, y=y, by=by, **kwds)
  File "C:\repos\private\hvplot\hvplot\plotting\core.py", line 92, in __call__
    return self._get_converter(x, y, kind, **kwds)(kind, x, y)
  File "C:\repos\private\hvplot\hvplot\converter.py", line 1240, in __call__
    obj = method(x, y)
  File "C:\repos\private\hvplot\hvplot\converter.py", line 1820, in hist
    hists = histogram(ds, dimension=y, **hist_opts)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\param\parameterized.py", line 3654, in __new__
    return inst.__call__(*args,**params)
  File "c:\repos\private\tmp\holoviews\holoviews\core\operation.py", line 220, in __call__
    return element.apply(self, **kwargs)
  File "c:\repos\private\tmp\holoviews\holoviews\core\accessors.py", line 45, in pipelined_call
    result = __call__(*args, **kwargs)
  File "c:\repos\private\tmp\holoviews\holoviews\core\accessors.py", line 202, in __call__
    new_obj = apply_function(self._obj, **inner_kwargs)
  File "c:\repos\private\tmp\holoviews\holoviews\core\operation.py", line 214, in __call__
    return self._apply(element)
  File "c:\repos\private\tmp\holoviews\holoviews\core\operation.py", line 141, in _apply
    ret = self._process(element, key)
  File "c:\repos\private\tmp\holoviews\holoviews\operation\element.py", line 785, in _process
    null_hist_range = hist_range == (0, 0)
  File "C:\repos\private\hvplot\.venv\lib\site-packages\ibis\expr\types\core.py", line 68, in __bool__
    raise ValueError(
ValueError: The truth value of an Ibis expression is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant