diff --git a/TM1py/Services/CellService.py b/TM1py/Services/CellService.py index 4210ba95..902f45f6 100644 --- a/TM1py/Services/CellService.py +++ b/TM1py/Services/CellService.py @@ -2798,13 +2798,15 @@ def extract_cellset_dataframe( @tidy_cellset @require_pandas def extract_cellset_dataframe_shaped(self, cellset_id: str, sandbox_name: str = None, - display_attribute: bool = False, **kwargs) -> 'pd.DataFrame': + display_attribute: bool = False, infer_dtype: bool = False, **kwargs) -> 'pd.DataFrame': """ Retrieves data from cellset in the shape of the query. Dimensions on rows can be stacked. One dimension must be placed on columns. Title selections are ignored. :param cellset_id :param sandbox_name: str :param display_attribute: bool, show element name or first attribute from MDX PROPERTIES clause + :param infer_dtype: bool, if True, lets pandas infer dtypes, otherwise all columns will be of type str. + """ url = "/api/v1/Cellsets('{}')?$expand=" \ "Axes($filter=Ordinal eq 0 or Ordinal eq 1;$expand=Tuples(" \ @@ -2860,7 +2862,10 @@ def extract_cellset_dataframe_shaped(self, cellset_id: str, sandbox_name: str = for element_tuple, cells in zip(element_names_by_row, cell_values_by_row): body.append(list(element_tuple) + cells) - return pd.DataFrame(body, columns=headers, dtype=str) + if infer_dtype: + return pd.DataFrame(body, columns=headers) + else: + return pd.DataFrame(body, columns=headers, dtype=str) @require_pandas def extract_cellset_dataframe_pivot(self, cellset_id: str, dropna: bool = False, fill_value: bool = False,