Reference cells
Reference cells from Python.
In Quadratic, reference tables and named outputs from Python for simplest references, reference individual cells from Python for single values or reference a range of cells for multiple values.
Referencing tables (and named outputs)
Much of Quadratic's data is formatted in Data Tables for ease of use. Data Tables also make references more straightforward. To reference a table you can use q.cells
which will bring the table into a DataFrame.
All code outputs are also named and in tables by default; they can be referenced in the same fashion, using their names. Wherever possible you are encouraged to perform references using tables for simplest possible user experience.
Referencing individual cells
To reference an individual cell, use the global function q.cells
which returns the cell value.
You can reference cells and use them directly in a Pythonic fashion.
Any time cells dependent on other cells update, the dependent cell will also update. This means your code will execute in one cell if it is dependent on another. This is the behavior you want in almost all situations, including user inputs in the sheet that cause calculation in a Python cell.
Referencing a range of cells
To reference a range of cells, use the same global function q.cells()
which returns a Pandas DataFrame.
If the first row of cells is a header, you should set first_row_header
as an argument. This makes the first row of your DataFrame the column names, otherwise will default to integer column names as 0, 1, 2, 3, etc.
Use first_row_header when you have column names that you want as the header of the DataFrame. This should be used very commonly. You can tell when a column name should be a header when the column name describes the data below.
Referencing another sheet
To reference another sheet's table, individual cells, or range of cells use the following:
Unbounded references
Unbounded column references
To reference all the data in a column or set of columns without defining the range, use the following syntax.
Unbounded column references span from the row set (row 1 if not defined) to wherever the content in that column ends. Ranged references are always returned as DataFrames. Wherever gaps in data exist, None
is filled in instead.
Unbounded row references
To reference all the data in a row or set of rows without defining the range, use the following syntax.
Row references span from the row set to wherever the content in that row ends.
Relative vs absolute references
By default when you copy paste a reference it will update the row reference unless you use $
notation in your references.
Last updated
Was this helpful?