diff --git a/google/colab/sheets.py b/google/colab/sheets.py index 2fd54dd..7639b41 100644 --- a/google/colab/sheets.py +++ b/google/colab/sheets.py @@ -182,15 +182,16 @@ def as_df(self): data = self.storage_strategy.read(self.worksheet) return pd.DataFrame(data) - def update(self, df): + def update(self, df, **kwargs): """Update clears the sheet and replaces it with the provided dataframe. Args: df: the source data + **kwargs: additional arguments to pass to the gspread update method """ self._ensure_gspread_client() self.worksheet.clear() - self.storage_strategy.write(self.worksheet, _to_frame(df)) + self.storage_strategy.write(self.worksheet, _to_frame(df), **kwargs) def display(self, height=600): """Display the embedded sheet in Colab. @@ -211,7 +212,7 @@ def read(self, worksheet): pass @abc.abstractmethod - def write(self, worksheet, df): + def write(self, worksheet, df, **kwargs): pass @@ -222,9 +223,9 @@ def read(self, worksheet): data = worksheet.get_values() return pd.DataFrame(data) - def write(self, worksheet, df): + def write(self, worksheet, df, **kwargs): data = [list(r) for _, r in df.iterrows()] - worksheet.update('', data) + worksheet.update('', data, **kwargs) class HeaderStorageStrategy(InteractiveSheetStorageStrategy): @@ -234,6 +235,6 @@ def read(self, worksheet): data = worksheet.get_all_records() return pd.DataFrame(data) - def write(self, worksheet, df): + def write(self, worksheet, df, **kwargs): data = [list(df.columns)] + [list(r) for _, r in df.iterrows()] - worksheet.update('', data) + worksheet.update('', data, **kwargs)