[Python] Using Polars data in Django template html

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    lets start with their demo.

    df = pl.DataFrame(
    {
    "foo": [1, 2, 3],
    "bar": [6, 7, 8],
    }
    )
    df.write_json()

    '[{"foo":1,"bar":6},{"foo":2,"bar":7},{"foo":3,"bar":8}]'


    I pass in the df in the from the df.write_json()

    context = {

    'df' : df,
    }


    But nothing i am trying in Django is working? the json was the only option i see to pass the data.

    techinally this is a list of dicts?

    <ul>
    {% for i in df %} # tried many option here

    {{ i.foo }}

    {% endfor %}
    <ul>


    i have tried all sorts of things.

    for Pandas i would just use df.to_records()

    what is best way to get Polars data into a Django template to use in things like tables?

    loving polars so far but getting confused by a few things. Like this one.

    Thanks!

    Continue reading...

Compartilhe esta Página