[Python] How to display Polars list columns in NiceGUI

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    I’m migrating from Streamlit to NiceGUI and noticed a difference in how DataFrames with list columns are handled.

    With Streamlit:

    import polars as pl
    import streamlit as st

    df = pl.DataFrame({
    "a": [1, 2, 3],
    "b": [4, 5, 6],
    "c": [[1, 2], [3, 4], [5, 6]],
    })

    st.write(df)


    Column c is shown as a list: [1, 2], [3, 4], [5, 6].

    With NiceGUI:

    import polars as pl
    from nicegui import ui

    df = pl.DataFrame({
    "a": [1, 2, 3],
    "b": [4, 5, 6],
    "c": [[1, 2], [3, 4], [5, 6]],
    })

    ui.table.from_polars(df)
    ui.run()


    Column c gets concatenated into a string instead of being displayed as a list.

    So ,i’m looking for is a way to achieve a result similar to what I get with my Streamlit script.

    PD: The transformation using the method from_polars() make the program really slow.

    Continue reading...

Compartilhe esta Página