atoti.simulation module¶
-
class
atoti.simulation.
Scenario
(name, _simulation, _java_api)¶ A scenario for a simulation.
-
append
(*rows)¶ Add one or multiple rows to the scenario.
If a row with the same keys already exist in the scenario, it will be overridden by the passed one.
-
property
columns_without_priority
¶ Columns of the scenario (Priority column excluded).
-
head
(n=5)¶ Return n rows of the scenario as a pandas DataFrame.
- Return type
DataFrame
-
load_csv
(path, *, sep=',')¶ Load a CSV into this scenario.
The expected columns are
columns
orcolumns_without_priority
.The name of the scenario is automatically added before the row is added to the simulation store.
If the value of a column is left empty (
None
), then it will be treated as a wildcard value. i.e. it will match all the values of the corresponding column when performing the simulation.If a value for a column on a given row is empty, it will be treated as a wildcard, meaning that it will match all the values of the corresponding column when performing the simulation.
-
load_pandas
(dataframe, **kwargs)¶ Load a pandas DataFrame into this scenario.
The expected columns are
columns
orcolumns_without_priority
.The name of the scenario is automatically added before the row is added to the simulation store.
If the value of a column is left empty (
None
), then it will be treated as a wildcard value. i.e. it will match all the values of the corresponding column when performing the simulation.- Parameters
dataframe (
DataFrame
) – The DataFrame to load.
-
-
class
atoti.simulation.
Simulation
(_name, _levels, _multiply, _replace, _add, _base_scenario, _cube, _java_api)¶ Represents a simulation.
-
property
columns_without_priority
¶ Columns of the simulation (Priority column excluded).
-
head
(n=5)¶ Return n rows of the simulation as a pandas DataFrame.
- Return type
DataFrame
-
load_csv
(path, *, sep=None, encoding='utf-8', process_quotes=True, watch=False, array_sep=None)¶ Load a CSV into this simulation.
The expected columns are
columns
orcolumns_without_priority
.The value provided for
simulation_name
is the name of the scenario the values will be loaded into.If the value of a column is left empty (
None
), then it will be treated as a wildcard value, meaning that it will match all the values of the corresponding column when performing the simulation.If a value for a specific field is left empty, it wil be treated as a wildcard value, meaning that it will match all the values of the corresponding column when performing the simulation.
- Parameters
The path to the CSV file or directory to load.
If a path pointing to a directory is provided, all of the files with the
.csv
extension in the directory and subdirectories will be loaded into the same store and, as such, they are all expected to share the same schema..gz
,.tar.gz
and.zip
files containing compressed CSV(s) are also supported.The path can contain glob parameters (e.g.
path/to/directory/**.*.csv
) and will be expanded correctly. Be careful, when using glob expressions in paths, all files which match the expression will be loaded, regardless of their extension. When the provided path is a directory, the default glob parameter of**.csv
is used.sep (
Optional
[str
]) – The delimiter to use. IfNone
, the separator will automatically be detected.encoding (
str
) – The encoding to use to read the CSV.process_quotes (
bool
) –Whether double quotes should be processed to follow the official CSV specification:
True
:Each field may or may not be enclosed in double quotes (however some programs, such as Microsoft Excel, do not use double quotes at all). If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.
A double quote appearing inside a field must be escaped by preceding it with another double quote.
Fields containing line breaks, double quotes, and commas should be enclosed in double-quotes.
False
: all double-quotes within a field will be treated as any regular character, following Excel’s behavior. In this mode, it is expected that fields are not enclosed in double quotes. It is also not possible to have a line break inside a field.None
: The behavior will be inferred from the first lines of the CSV file.
watch (
bool
) – Whether the source file or directory at the given path should be watched for changes. When set toTrue
, changes to the source will automatically be reflected in the store. If the source is a directory, new files will be loaded into the same store as the initial data and must therefore have the same schema as the initial data as well. Any non-CSV files added to the directory will be ignored.array_sep (
Optional
[str
]) – The delimiter to use for arrays. Setting it to a non-None
value will parse all the columns containing this separator as arrays.
-
load_pandas
(dataframe, **kwargs)¶ Load a pandas DataFrame into this simulation.
The expected columns are
columns
orcolumns_without_priority
.The value provided for
simulation_name
is the name of the scenario the values will be loaded into.If the value of a column is left empty (
None
), then it will be treated as a wildcard value, meaning that it will match all the values of the corresponding column when performing the simulation.If the value of a column is left empty (
None
), it will be treated as a wildcard value, meaning that it will match all the values of the corresponding column when performing the simulation.- Parameters
dataframe (
DataFrame
) – The DataFrame to load.
-
property
scenarios
¶ Scenarios of the simulation.
- Return type
-
property
-
class
atoti.simulation.
SimulationScenarios
(_simulation)¶ Manage the scenarios of a simulation.