Skip to content

Commit

Permalink
Align write_dataframe function with write function
Browse files Browse the repository at this point in the history
Add new parameters to `write_dataframe` function
  • Loading branch information
MariusWirtz committed Feb 6, 2022
1 parent 48d7f84 commit 90e7284
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions TM1py/Services/CellService.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ def get_dimension_names_for_writing(self, cube_name: str, **kwargs) -> List[str]
def write_dataframe(self, cube_name: str, data: 'pd.DataFrame', dimensions: Iterable[str] = None,
increment: bool = False, deactivate_transaction_log: bool = False,
reactivate_transaction_log: bool = False, sandbox_name: str = None,
use_ti: bool = False, use_changeset: bool = False, **kwargs) -> str:
use_ti: bool = False, use_changeset: bool = False, precision: int = 8,
skip_non_updateable: bool = False, measure_dimension_elements: Dict = None, **kwargs) -> str:
"""
Function expects same shape as `execute_mdx_dataframe` returns.
Column order must match dimensions in the target cube with an additional column for the values.
Expand All @@ -417,8 +418,13 @@ def write_dataframe(self, cube_name: str, data: 'pd.DataFrame', dimensions: Iter
:param sandbox_name:
:param use_ti:
:param use_changeset: Enable ChangesetID: True or False
:param kwargs:
:return: ChangeSet: str
:param precision: max precision when writhing through unbound process.
Necessary when dealing with large numbers to avoid "number too long" TI syntax error.
:param skip_non_updateable skip cells that are not updateable (e.g. rule derived or consolidated)
:param measure_dimension_elements: dictionary of measure elements and their types to improve
performance when `use_ti` is `True`.
When all written values are numeric you can pass a default dict with default key 'Numeric'
:return: changeset or None
"""
if not isinstance(data, pd.DataFrame):
raise ValueError("argument 'data' must of type DataFrame")
Expand All @@ -440,6 +446,9 @@ def write_dataframe(self, cube_name: str, data: 'pd.DataFrame', dimensions: Iter
sandbox_name=sandbox_name,
use_ti=use_ti,
use_changeset=use_changeset,
precision=precision,
skip_non_updateable=skip_non_updateable,
measure_dimension_elements=measure_dimension_elements,
**kwargs)

@manage_transaction_log
Expand Down

0 comments on commit 90e7284

Please sign in to comment.