
import pygsheets
path='G:\\My drive\\testing\\google-sheet\\creds1.json'
gc=pygsheets.authorize(service_account_file=path)
sh=gc.create('my_sheet1',folder_name='python-test')
set_dataframe(df, start, copy_index=False, copy_head=True,
extend=False, fit=False, escape_formulae=False, **kwargs)
| Options | Details |
|---|---|
| df | Pandas DataFrame |
| start | Staring Point tuple ( row, column). It is (1,1) in below example |
| copy_index | Default False, Copy Index data from DataFrame |
| copy_head | True ( default ), column headers of Pandas DataFrame is copied. |
| extend | False( default) If required add columns and rows ( see example ) |
| fit | False(default), Resize to fit all data in DataFrame if required |
| escape_formulae | How to handle formula ( value with = or +- sign ) |
| nan | Replace NaN values with |
wk1=sh[0] # first worksheet
import pandas as pd # importing Pandas library
my_dict={
'NAME':['Ravi','Raju','Alex'],
'ID':[1,2,3],'MATH':[30,40,50],
'ENGLISH':[20,30,40]
}
df = pd.DataFrame(data=my_dict) # creating DataFrame
wk1.set_dataframe(df,(1,1))
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.