Define DataFrame lower-right cells in `GSheetsClient.to_frame`
Description
Incorporate a way to bound the cells selected by GSheetsClient.to_frame
via a right-most and/or lower-most limit.
Motivation
When defining tables in GSheets, someone may be tempted to define more than one table in the same sheet, as shows the screenshot attached:
In the example above, one table is defined by the range A2:B5
and the other by the range D2:F4
.
A user calling to_frame
with first_cell_loc="D2"
may expect the second table to be returned. Currently, the function will return a DataFrame
which has the second table's first column as the first column, but will eventually incorporate all columns in the order that they occur in the second row and treat them as part of the same table.
Proposal
It may be useful to incorporate a mechanism to bound the table's range, which would allow to fetch both tables as the following individual DataFrames:
In [ ]: df1
Out[ ]:
parameter value
0 percentage_change_roas 10
1 percentage_change_spend 50
2 lowest_cost_percentage 70
In [ ]: df2
Out[ ]:
weekday lower_campaign_spend_change upper_campaign_spend_change
0 Monday 50 20
1 Tuesday 50 20
2 Wednesday 50 20
3 Thursday 30 40
4 Friday 20 60
5 Saturday 20 100
6 Sunday 20 100
in one of two ways:
-
Explicitly, through parameters like
last_row
,last_col
, andlast_cell_loc
. The above DataFrames could then be fetched as:df1 = to_frame(sheet_id, last_col="B")
df2 = to_frame(sheet_id, first_cell_loc="D1", last_cell_loc="F8")
-
Implicitly, by stopping lecture at all-empty rows and columns. The above DataFrames would be fetched as
df1 = to_frame(sheet_id)
df2 = to_frame(sheet_id, first_cell_loc="D1")
Drawbacks
- Having two tables in the same sheet may be considered sloppy.
- A completely empty row may be expected by some user. This could be patched by incorporating a boolean parameter such as
stop_at_empty_rows
set to the proper default.