DataFrame
refers to a data structure that stores data in rows and columns in a way similar to a spreadsheet or SQL table.DataFrame
data structure in your code and then bind it to a UI Dataframe.
Create a DataFrame data structure
DataFrame
data structures. Create a DataFrame
, assign its value to a variable, then assign make that variable a value in the state
dictionary:wf.init_state()
adds the DataFrame
to the application’s state
variable as the value of the mydf
key.Add a DataFrame component to the UI and bind it to the DataFrame data structure
@{
dataframe_key}
, where dataframe_key is the state
variable key whose value refers to the DataFrame
data structure.In the case of this example, mydf
is the state
variable key referring to the DataFrame
, so set the Data property to @{mydf}
.EditableDataFrame
, a class provided by the Writer library. Changes to a EditableDataFrame
object will be immediately reflected in the DataFrame UI component that it is bound to.
Create an EditableDataFrame data structure
EditableDataFrame
object can be instantiated from any of the following:DataFrame
DataFrame
wf.init_state()
adds the DataFrame
to the application’s state
variable as the value of the mydf
key.Add a DataFrame component to the UI and bind it to the DataFrame data structure
@{
dataframe_key}
, where dataframe_key is the state
variable key whose value refers to the DataFrame
data structure.In the case of this example, mydf
is the state
variable key referring to the DataFrame
, so set the Data property to @{mydf}
.EditableDataFrame
object they are bound to, which is done using EditableDataFrame
’s methods.
record_add
: Add a new rowrecord_add()
adds a new row to an EditableDataFrame
. It takes a dictionary with the following structure…
new_row
is a dictionary containing the data for the row to be added.
In the code example above, you would add a new row to the DataFrame with the following code:
record
: Read the contents of a rowrecord()
returns a row in an EditableDataFrame
. It takes an integer specifying the index of the row.
In the code example above, you would retrieve the record at row 1 with the following code:
record_update
: Change an existing rowrecord_update()
replaces an existing row in an EditableDataFrame
with a new one. It takes a dictionary with the following structure…
index
is an integer specifying which row should be updated and row_to_update
is a dictionary containing the updated row data.
In the code example above, you would update the row at index 0 with the following code:
record_remove
: Delete an existing rowrecord_remove()
removes an existing row from an EditableDataFrame
. It takes a dictionary with the following structure…
index
is an integer specifying which row should be deleted.
In the code example above, you would delete the row at index 2 with the following code: