There are four different upload strategies available:

  1. New table
  2. Append
  3. Replace
  4. Merge

1. New table

New table is the default strategy. It will always create a new table.

main.py
import pandas as pd

# example data
emissions_df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/Emissions%20Data.csv")

table = rho_client.store_df(
    emissions_df,
    name="emissions_data",
    strategy="NEW_TABLE"  # default strategy, can be omitted
)
print(table.client_url)

2. Append

Append strategy will append the data to the existing table. To append, you need to specify the table_id of the table you want to append to.

main.py
import pandas as pd

# example data
initial_data = pd.DataFrame({"value": [i for i in range(10, start=1)]})

# create new table
table = rho_client.store_df(
    initial_data,
    name="append_demo"
)
# append more data
more_data = pd.DataFrame({"value": [i for i in range(10, start=11)]})
table = rho_client.store_df(
    more_data,
    table_id=table.table_id,
    strategy="APPEND"
)
print(table.client_url)

The method is also available on the Table object:

3. Replace

The replace strategy will replace the data in the existing table. To replace, you need to specify the table_id of the table you want to replace.

main.py
import pandas as pd

# example data
initial_data = pd.DataFrame({"value": [i for i in range(10, start=1)]})

# create new table
table = rho_client.store_df(
    initial_data,
    name="replace_demo"
)
# replace the data
new_data = pd.DataFrame({"value": [i for i in range(10, start=11)]})
table = rho_client.store_df(
    new_data,
    table_id=table.table_id,
    strategy="REPLACE"
)
print(table.client_url)

There is a shorthand for the method available on the Table-object:

4. Merge

The merge strategy will merge the data in the existing table. To merge, you need to specify the table_id of the table you want to merge. You also need to specify the column to merge on. The merge strategy will merge the data on the specified column. The merge-column must be a unique column in both tables.

main.py
import pandas as pd

# example data
initial_data = pd.DataFrame({"value": [i for i in range(10, start=1)]})

# create new table
table = rho_client.store_df(
    initial_data,
    name="replace_demo"
)
# merge on specific column
new_data = pd.DataFrame({"value": [i for i in range(20, start=1)]})
table = rho_client.store_df(
    new_data,
    table_id=table.table_id,
    strategy="MERGE",
    merge_options={"column": "value"}
)
print(table.client_url)

There is a shorthand for the method available on the Table-object: