pygsheets icon indicating copy to clipboard operation
pygsheets copied to clipboard

Worksheet.set_dataframe throws error AttributeError: 'NoneType' object has no attribute 'MultiIndex'

Open mutiev opened this issue 4 years ago • 4 comments

# write pandas df to google sheets
import pandas as pd
import pygsheets as pgs


c = pgs.authorize(...)
s = c.open_by_key(spreadsheet_id)
w = s.sheet1
df = pd.DataFrame({"id":[1,2,3],"val":["A","B","C"]})

print(df.columns)
print(isinstance(df.columns, pd.MultiIndex))

! w.set_dataframe(df=df, start="A8")

>>
Index(['id', 'val'], dtype='object')
False

! ----
- **AttributeError**: 'NoneType' object has no attribute 'MultiIndex'

image

mutiev avatar Jan 16 '22 18:01 mutiev

nah, after reauthorizing it's works fine. There problem with expired session. While working with pygsheets via jupyter I haven't seen any warning messages about expiration

mutiev avatar Jan 16 '22 19:01 mutiev

What do you mean by reauthorizing?

juliovelazquezDA avatar Jun 29 '22 21:06 juliovelazquezDA

What do you mean by reauthorizing? I mean this s = c.open_by_key(spreadsheet_id) s is session I split code in jupyter in two blocks. First block initializes session. Second block manipulates with data. So I run just once init block, init session and then worked only with second block. When session is died pygsheets gives me error of this topic. It confused me first time

mutiev avatar Jun 30 '22 02:06 mutiev

I am facing the Same Issue, One Jupiter file code runs without any error then other facing issues but sometimes shows this error in all files, randomly start showing that function as part of the lib and working well, bit confusing

kzatakia avatar Aug 21 '23 08:08 kzatakia