Получение ошибки атрибута при синхронизации Jupyter NB с Google Sheets - PullRequest
0 голосов
/ 18 июня 2020

Я пытаюсь интегрировать свой Jupyter Notebook с Google Sheets. Я пытаюсь выполнить приведенный ниже код, и он дает мне ошибку атрибута. Нужна ваша помощь, чтобы решить эту же проблему.

# Set the sheet name you want to upload data to and the start cell where the upload data begins 
wks_name = 'Sheet1'
cell_of_start_df = 'A2'
# upload the dataframe of the clients we want to delete
d2g.upload(rs,
           spreadsheet_key,
           wks_name,
           credentials=credentials,
           col_names=False,
           row_names=False,
           start_cell = cell_of_start_df,
           clean=False)
print ('The sheet is updated successfully')

Я получаю сообщение об ошибке ниже:

AttributeError                            Traceback (most recent call last)
<ipython-input-30-6aac4a76409f> in <module>
     10            row_names=False,
     11            start_cell = cell_of_start_df,
---> 12            clean=False)
     13 print ('The sheet is updated successfully')

~\Anaconda3\lib\site-packages\df2gspread\df2gspread.py in upload(df, gfile, wks_name, col_names, row_names, clean, credentials, start_cell, df_size, new_sheet_dimensions)
     99     last_idx = num_rows + last_idx_adjust
    100 
--> 101     num_cols = len(df.columns) + 1 if row_names else len(df.columns)
    102     last_col_adjust = start_col_int - 1
    103     last_col_int = num_cols + last_col_adjust

~\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5268             or name in self._accessors
   5269         ):
-> 5270             return object.__getattribute__(self, name)
   5271         else:
   5272             if self._info_axis._can_hold_identifiers_and_holds_name(name):

AttributeError: 'Series' object has no attribute 'columns'

Это будет большим подспорьем, если она будет решена.

Дополнительно Код:

cols = ['Cases']
mask = lk[cols].applymap(lambda x: isinstance(x, (int, float)))

lk[cols] = lk[cols].where(mask)
print (lk)

mn = lk.replace('NaN',0)
mn


rs=mn.groupby(['States and UTs','district','status'])[mn.columns[0]].sum()
rs

...