Skip to content

Commit 28d11fa

Browse files
author
jpaten
committed
chore: added missing docstrings in analytics package (#4353)
1 parent 38a1258 commit 28d11fa

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

analytics/analytics_package/analytics/api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def build_params(source, subs):
297297

298298

299299
def results_to_df(results):
300-
301300
df = pd.DataFrame()
302301
for result in results:
303302
# Collect column nmes

analytics/analytics_package/analytics/sheets_api.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,19 @@ def update_sheet_raw(sheets_authentication_response, sheet, *updates):
377377

378378
@dataclass
379379
class WorksheetRange:
380+
"""
381+
A dataclass to represent a range of cells in a worksheet in the one-sided interval [top_left, bottom_right).
382+
:param worksheet: the gspread.worksheet.Worksheet object
383+
:param top_left: the top left cell of the range. This cell will be included in the range
384+
:param bottom_right: the bottom right cell of the range. This cell will not be included in the range
385+
"""
380386
worksheet: gspread.worksheet.Worksheet
381387
top_left: gspread.cell.Cell
382388
bottom_right: gspread.cell.Cell
383389

384390
@property
385391
def range_dict(self):
392+
"""The range as a dictionary for the sources field in the Google Sheets api"""
386393
return {
387394
"sheetId": self.worksheet.id,
388395
"startRowIndex": self.top_left.row - 1,
@@ -399,6 +406,16 @@ def _cell_to_grid_coordinate(cell, worksheet):
399406
}
400407

401408
def add_chart_to_sheet(sheets_authentication_response, sheet, worksheet, chart_type, domain, series, **chart_args):
409+
"""
410+
Add a chart to a specified workshet
411+
:param sheets_authentication_response: the response from ga.authenticate. Must be for the sheets api v4
412+
:param sheet: the gspread.Spreadsheet object
413+
:param worksheet: the gspread.Worksheet object
414+
:param chart_type: the type of chart to add
415+
:param domain: the domain of the chart as a WorksheetRange. Must contain either one row or one column
416+
:param series: the series of the chart as a WorksheetRange. Must contain either one row or one column
417+
:param chart_args: other arguments to create the chart. See DEFAULT_CHART_ARGS
418+
"""
402419
complete_chart_args = {**DEFAULT_CHART_ARGS, **chart_args}
403420
if complete_chart_args["chart_position"] is not None:
404421
position_dict = {
@@ -415,7 +432,6 @@ def add_chart_to_sheet(sheets_authentication_response, sheet, worksheet, chart_t
415432
formatted_domains = [
416433
{
417434
"domain": {
418-
#TODO: would be nice to also support column references https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/other#DataSourceColumnReference
419435
"sourceRange": {
420436
"sources": [
421437
domain.range_dict
@@ -425,6 +441,7 @@ def add_chart_to_sheet(sheets_authentication_response, sheet, worksheet, chart_t
425441
"reversed": complete_chart_args["invert_x_axis"],
426442
},
427443
]
444+
428445
formatted_series = [
429446
{
430447
"series": {

0 commit comments

Comments
 (0)