Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
10.83k stars 549 forks source link

[BUG] Index out of bounds on reading a dataframe #516

Closed RaulVS14 closed 3 months ago

RaulVS14 commented 3 months ago

Describe the bug Trying to read in 10000+ row dataframe. Getting an error: IndexError: index 10001 is out of bounds for axis 0 with size 10001

Traceback:
File "/app/app.py", line 83, in <module>
    main()
File "/app/app.py", line 78, in main
    analytics_tab()
File "/app/tabs/pygwalker_analytics/analytics_tab.py", line 146, in analytics_tab
    renderer.render_explore()
File "/usr/local/lib/python3.11/site-packages/pygwalker/api/streamlit.py", line 201, in render_explore
    html = self._get_html(**{"defaultTab": default_tab})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pygwalker/api/streamlit.py", line 147, in _get_html
    return self._get_html_with_params_str_cache(params_str)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/cachetools/__init__.py", line 737, in wrapper
    v = func(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pygwalker/api/streamlit.py", line 119, in _get_html_with_params_str_cache
    props = self.walker._get_props("streamlit")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pygwalker/api/pygwalker.py", line 530, in _get_props
    "fieldMetas": self.data_parser.field_metas,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pygwalker/data_parsers/base.py", line 138, in field_metas
    duckdb.register("pygwalker_mid_table", self._duckdb_df)

Versions

Additional context Similar issue was mentioned in: https://github.com/duckdb/duckdb/issues/10750 Recently DuckDB released PR to fix that issue with: 0.10.1 Bugfix Release .

I think this would be solved with DuckDB version requirement update from 0.10.0 -> 0.10.1

longxiaofei commented 3 months ago

Thanks for your feedback.

I just released a pre-release version to fix it: pip install pygwalker==0.4.8a11.

Or you can force update the duckdb version and ignore the dependency warning of pygwalker(0.4.7).

RaulVS14 commented 3 months ago

I will use the pre-release. Ignoring dependency warning isn't available choice, because I install with requirements.txt and pip refuses to install.

One thing I noticed while trying it out is that for some reason displayed view goes dark mode by default, even though I have light mode used in streamlit.

longxiaofei commented 3 months ago

Did you specify a streamlit theme?

example:

[theme]
base="light"
RaulVS14 commented 3 months ago

Yes, I have these exact lines in my config file.

ObservedObserver commented 3 months ago

pygwalker by default use system appearance. In your case, it seems your system is dark theme while your streamlit is light theme. You can change the appearance of pygwalker:

import pygwalker as pyg

pyg.walk(df, appearance='light')

# or in streamlit
from pygwalker.api.streamlit import StreamlitRenderer
StreamlitRenderer(appearance='light')
RaulVS14 commented 3 months ago

Great, thanks for explaining! Problem solved :)