Initializing help system before first use

xpressinsight.scenario.ArrayUpdate

Purpose
Representation of an update to the applied to the value of an array entity.
Synopsis
class xpressinsight.ArrayUpdate(scenario.EntityUpdate)
Arguments
entity_name: str 
The name of the entity being updated.
add: Union[Dict, pd.Series, pl.DataFrame] 
The list of values to add or update in the array. May be a Dictionary, a Pandas Series or a Polars DataFrame. If a Polars DataFrame, it's assumed the rightmost column is the value, and the other columns are the index values, in the same order as specified in the Insight schema. If a Dictionary, the keys may be single values (for a single-index array), or tuples (for a multi-index array).
remove: Union[Iterable, pd.Index, pl.DataFrame] 
A list of index entries to remove from the array. May be an Iterable, a Pandas Index or a Polars DataFrame. If a Pandas Index, it should be a MultiIndex if the array has multiple indexes. If a Polars DataFrame, it's assumed that each column represents one of the index entities, in the same other as specified in the Insight schema. Otherwise, it should be an iterable containing either the index values to remove (for a single-index array), or tuples (for a multi-index array).
Example
Add or update values in the single-index array 'DAY_NAMES':
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_add = {6: 'Saturday', 7: 'Sunday'}
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('DAY_NAMES', add=entries_to_add)])			
Add or update values in the multi-index array 'SALES':
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_add = {('Washington', 'January'): 25.1,
...                       ('Washington', 'February'): 30.7,
...                       ('Delaware', 'January'): 2.0}
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', add=entries_to_add)])			
Add or update values in the multi-index array 'SALES', using a Pandas series:
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_add = pd.Series([25.1, 30.7, 2.0],
...         index=pd.MultiIndex.from_tuples([('Washington', 'January'),
...                                          ('Washington', 'February'),
...                                          ('Delaware', 'January')])
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', add=entries_to_add)])			
Add or update values in the multi-index array 'SALES', using a Polars data-frame:
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_add = pl.DataFrame({
...         'Location': ['Washington', 'Washington', 'Delaware'],
...         'Month': ['January', 'February', 'January'],
...         'Value': [25.1, 30.7, 2.0]})
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', add=entries_to_add)])			
Remove values from the single-index array 'DAY_NAMES':
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('DAY_NAMES', remove=[6, 7])])			
Remove values in the multi-index array 'SALES':
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', remove=[('Toronto', 'January'),
...                                      ('Toronto', 'February'),
...                                      ('Toronto', 'March')])])			
Remove values in the multi-index array 'SALES', using Pandas data-types:
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_remove = pd.MultiIndex.from_product([['Toronto'],
...             ['January', 'February', 'March']])
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', remove=entries_to_remove)])			
Remove values in the multi-index array 'SALES', using Polars data-types:
>>> with ins.InsightRestClient(insight_url='http://localhost:8080/') as client:
...     entries_to_remove = pl.DataFrame({
...         'Location': ['Toronto', 'Toronto', 'Toronto'],
...         'Month': ['January', 'February', 'March']})
...     client.update_scenario_data('570b9100-46e3-4643-baee-2e24aa538f25', [
...         ArrayUpdate('SALES', remove=entries_to_remove)])			
Further information
Whichever data type is used when passing the 'add' and 'remove' arguments, it must contain values of the required types for the value and indexes of this array entity.
Related topics

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.