[Python] How to add data in newly added row in ipysheet?

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    When I click on add row button Iam able to add new row but how to add data to that new row, Iam using data frames here ? Please find the executable code

    import qgrid,ipysheet
    from ipywidgets import widgets
    import numpy as np
    import pandas as pd

    #qgrid.show_grid(df,show_toolbar=True)

    random_data = [['ABC','DEF','GHI'],
    [0.69494459,0.90502388,0.13374771],
    [0.89609645,0.66166011,0.12123602],
    [0.51229257,0.57240808,0.25482961],
    [0.25478973,0.08438657,0.76977642]]

    df = pd.DataFrame(random_data, columns=["Col1", "Col2", "Col3"])
    sheet = ipysheet.from_dataframe(df)
    btn = wg.Button(description = 'Add Row')
    def on_bttn_clicked(b):
    sheet.rows += 1

    btn.on_click(on_bttn_clicked)

    display(btn,sheet)

    Continue reading...

Compartilhe esta Página