1
#For creating a new-sheet
sheets.add_worksheet(title=sheetName, rows=df.shape[0], cols=df.shape[1])

#For appending
values = df.values.tolist()
sheets.values_append(sheetName, {'valueInputOption': 'USER_ENTERED'}, {'values': values})

It creates a new worksheet but there are no column names in it only the values.

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Subham
  • 160
  • 2
  • 10

1 Answers1

0

In your script, how about the following modification?

From:

values = df.values.tolist()

To:

values = [df.columns.values.tolist()] + df.values.tolist()
  • By this, values has the data including the header row.
Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • @ Tanaike Would you help me out with this too? [https://stackoverflow.com/questions/71544103/how-can-we-store-a-json-credential-to-env-variable-in-python] – Subham Mar 20 '22 at 05:01
  • @Subham I would like to check it. When I could correctly understand your new question and I got the answer, I would like to answer it. – Tanaike Mar 20 '22 at 05:04
  • Okay no problem. – Subham Mar 20 '22 at 05:19