[Python] How to delete a row in Google Sheets getting the max of a column?

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    I need to read the Google sheet and getting the max value of a column and deleting the data to update them.

    I tried to get the max value and pass to delete_rows method, but don't work well.

    spreadsheet = client.open("Test")
    worksheet = spreadsheet.worksheet("Test")
    data = worksheet.get_all_records(head = 1, value_render_option= 'UNFORMATTED_VALUE')
    dataPag = worksheet.col_values(8, value_render_option= 'UNFORMATTED_VALUE')[-1:] # Get the max value of column


    Here an example in Pandas what I need

    df = pd.DataFrame(data)

    max = df['pages'].max()
    dropLastValueDf = df.loc[(df['pages']) == max]
    dfPages = df.drop(dropLastValueDf.index)


    Anyone have an idea that can help me ?

    Continue reading...

Compartilhe esta Página