gooddata-pandas 1.18.1__py3-none-any.whl → 1.18.2.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gooddata-pandas might be problematic. Click here for more details.
- gooddata_pandas/result_convertor.py +53 -23
- {gooddata_pandas-1.18.1.dist-info → gooddata_pandas-1.18.2.dev2.dist-info}/METADATA +3 -3
- {gooddata_pandas-1.18.1.dist-info → gooddata_pandas-1.18.2.dev2.dist-info}/RECORD +6 -6
- {gooddata_pandas-1.18.1.dist-info → gooddata_pandas-1.18.2.dev2.dist-info}/LICENSE.txt +0 -0
- {gooddata_pandas-1.18.1.dist-info → gooddata_pandas-1.18.2.dev2.dist-info}/WHEEL +0 -0
- {gooddata_pandas-1.18.1.dist-info → gooddata_pandas-1.18.2.dev2.dist-info}/top_level.txt +0 -0
|
@@ -200,12 +200,16 @@ class DataFrameMetadata:
|
|
|
200
200
|
|
|
201
201
|
row_totals_indexes: List[List[int]]
|
|
202
202
|
execution_response: BareExecutionResponse
|
|
203
|
+
primary_labels_from_index: Dict[int, Dict[str, str]]
|
|
204
|
+
primary_labels_from_columns: Dict[int, Dict[str, str]]
|
|
203
205
|
|
|
204
206
|
@classmethod
|
|
205
207
|
def from_data(
|
|
206
208
|
cls,
|
|
207
209
|
headers: Tuple[_DataHeaders, Optional[_DataHeaders]],
|
|
208
210
|
execution_response: BareExecutionResponse,
|
|
211
|
+
primary_labels_from_index: Dict[int, Dict[str, str]],
|
|
212
|
+
primary_labels_from_columns: Dict[int, Dict[str, str]],
|
|
209
213
|
) -> "DataFrameMetadata":
|
|
210
214
|
"""This method constructs a DataFrameMetadata object from data headers and an execution response.
|
|
211
215
|
|
|
@@ -219,6 +223,8 @@ class DataFrameMetadata:
|
|
|
219
223
|
return cls(
|
|
220
224
|
row_totals_indexes=row_totals_indexes,
|
|
221
225
|
execution_response=execution_response,
|
|
226
|
+
primary_labels_from_index=primary_labels_from_index,
|
|
227
|
+
primary_labels_from_columns=primary_labels_from_columns,
|
|
222
228
|
)
|
|
223
229
|
|
|
224
230
|
|
|
@@ -304,6 +310,7 @@ def _read_complete_execution_result(
|
|
|
304
310
|
def _create_header_mapper(
|
|
305
311
|
response: BareExecutionResponse,
|
|
306
312
|
dim: int,
|
|
313
|
+
primary_attribute_labels_mapping: Dict[int, Dict[str, str]],
|
|
307
314
|
label_overrides: Optional[LabelOverrides] = None,
|
|
308
315
|
use_local_ids_in_headers: bool = False,
|
|
309
316
|
use_primary_labels_in_attributes: bool = False,
|
|
@@ -315,6 +322,8 @@ def _create_header_mapper(
|
|
|
315
322
|
Args:
|
|
316
323
|
response (BareExecutionResponse): Response structure to gather dimension header details.
|
|
317
324
|
dim (int): Dimension id.
|
|
325
|
+
primary_attribute_labels_mapping (Dict[int, Dict[str, str]]): Dict to be filled by mapping of primary labels to
|
|
326
|
+
custom labels per level identified by integer.
|
|
318
327
|
label_overrides (Optional[LabelOverrides]): Label overrides. Defaults to None.
|
|
319
328
|
use_local_ids_in_headers (bool): Use local identifiers of header attributes and metrics. Optional.
|
|
320
329
|
Defaults to False.
|
|
@@ -336,10 +345,17 @@ def _create_header_mapper(
|
|
|
336
345
|
pass
|
|
337
346
|
elif "attributeHeader" in header:
|
|
338
347
|
if "labelValue" in header["attributeHeader"]:
|
|
348
|
+
label_value = header["attributeHeader"]["labelValue"]
|
|
349
|
+
primary_label_value = header["attributeHeader"]["primaryLabelValue"]
|
|
339
350
|
if use_primary_labels_in_attributes:
|
|
340
|
-
label =
|
|
351
|
+
label = primary_label_value
|
|
341
352
|
else:
|
|
342
|
-
label =
|
|
353
|
+
label = label_value
|
|
354
|
+
if header_idx is not None:
|
|
355
|
+
if header_idx in primary_attribute_labels_mapping:
|
|
356
|
+
primary_attribute_labels_mapping[header_idx][primary_label_value] = label_value
|
|
357
|
+
else:
|
|
358
|
+
primary_attribute_labels_mapping[header_idx] = {primary_label_value: label_value}
|
|
343
359
|
# explicitly handle '(empty value)' if it's None otherwise it's not recognizable in final MultiIndex
|
|
344
360
|
# backend represents ^^^ by "" (datasource value is "") or None (datasource value is NULL) therefore
|
|
345
361
|
# if both representation are used it's necessary to set label to unique header label (space) to avoid
|
|
@@ -382,7 +398,7 @@ def _headers_to_index(
|
|
|
382
398
|
label_overrides: LabelOverrides,
|
|
383
399
|
use_local_ids_in_headers: bool = False,
|
|
384
400
|
use_primary_labels_in_attributes: bool = False,
|
|
385
|
-
) -> Optional[pandas.Index]:
|
|
401
|
+
) -> Tuple[Optional[pandas.Index], Dict[int, Dict[str, str]]]:
|
|
386
402
|
"""Converts headers to a pandas MultiIndex.
|
|
387
403
|
|
|
388
404
|
This function converts the headers present in the response to a pandas MultiIndex (can be used in pandas dataframes)
|
|
@@ -398,10 +414,14 @@ def _headers_to_index(
|
|
|
398
414
|
Defaults to False.
|
|
399
415
|
|
|
400
416
|
Returns:
|
|
401
|
-
Optional[pandas.Index]: A pandas MultiIndex object created from the headers
|
|
417
|
+
Tuple[Optional[pandas.Index], Dict[int, Dict[str, str]]: A pandas MultiIndex object created from the headers
|
|
418
|
+
with primary attribute labels mapping as Dict, or None with empty Dict if the headers are empty.
|
|
402
419
|
"""
|
|
420
|
+
# dict of primary labels and it's custom labels for attributes per level as key
|
|
421
|
+
primary_attribute_labels_mapping: Dict[int, Dict[str, str]] = {}
|
|
422
|
+
|
|
403
423
|
if len(response.dimensions) <= dim_idx or not len(response.dimensions[dim_idx]["headers"]):
|
|
404
|
-
return None
|
|
424
|
+
return None, primary_attribute_labels_mapping
|
|
405
425
|
|
|
406
426
|
mapper = _create_header_mapper(
|
|
407
427
|
response=response,
|
|
@@ -409,6 +429,7 @@ def _headers_to_index(
|
|
|
409
429
|
label_overrides=label_overrides,
|
|
410
430
|
use_local_ids_in_headers=use_local_ids_in_headers,
|
|
411
431
|
use_primary_labels_in_attributes=use_primary_labels_in_attributes,
|
|
432
|
+
primary_attribute_labels_mapping=primary_attribute_labels_mapping,
|
|
412
433
|
)
|
|
413
434
|
|
|
414
435
|
return pandas.MultiIndex.from_arrays(
|
|
@@ -417,7 +438,7 @@ def _headers_to_index(
|
|
|
417
438
|
for header_idx, header_group in enumerate(cast(_DataHeaders, headers[dim_idx]))
|
|
418
439
|
],
|
|
419
440
|
names=[mapper(dim_header, None) for dim_header in (response.dimensions[dim_idx]["headers"])],
|
|
420
|
-
)
|
|
441
|
+
), primary_attribute_labels_mapping
|
|
421
442
|
|
|
422
443
|
|
|
423
444
|
def _merge_grand_totals_into_data(extract: _DataWithHeaders) -> Union[_DataArray, List[_DataArray]]:
|
|
@@ -507,24 +528,33 @@ def convert_execution_response_to_dataframe(
|
|
|
507
528
|
full_data = _merge_grand_totals_into_data(extract)
|
|
508
529
|
full_headers = _merge_grand_total_headers_into_headers(extract)
|
|
509
530
|
|
|
531
|
+
index, primary_labels_from_index = _headers_to_index(
|
|
532
|
+
dim_idx=0,
|
|
533
|
+
headers=full_headers,
|
|
534
|
+
response=execution_response,
|
|
535
|
+
label_overrides=label_overrides,
|
|
536
|
+
use_local_ids_in_headers=use_local_ids_in_headers,
|
|
537
|
+
use_primary_labels_in_attributes=use_primary_labels_in_attributes,
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
columns, primary_labels_from_columns = _headers_to_index(
|
|
541
|
+
dim_idx=1,
|
|
542
|
+
headers=full_headers,
|
|
543
|
+
response=execution_response,
|
|
544
|
+
label_overrides=label_overrides,
|
|
545
|
+
use_local_ids_in_headers=use_local_ids_in_headers,
|
|
546
|
+
use_primary_labels_in_attributes=use_primary_labels_in_attributes,
|
|
547
|
+
)
|
|
548
|
+
|
|
510
549
|
df = pandas.DataFrame(
|
|
511
550
|
data=full_data,
|
|
512
|
-
index=
|
|
513
|
-
|
|
514
|
-
headers=full_headers,
|
|
515
|
-
response=execution_response,
|
|
516
|
-
label_overrides=label_overrides,
|
|
517
|
-
use_local_ids_in_headers=use_local_ids_in_headers,
|
|
518
|
-
use_primary_labels_in_attributes=use_primary_labels_in_attributes,
|
|
519
|
-
),
|
|
520
|
-
columns=_headers_to_index(
|
|
521
|
-
dim_idx=1,
|
|
522
|
-
headers=full_headers,
|
|
523
|
-
response=execution_response,
|
|
524
|
-
label_overrides=label_overrides,
|
|
525
|
-
use_local_ids_in_headers=use_local_ids_in_headers,
|
|
526
|
-
use_primary_labels_in_attributes=use_primary_labels_in_attributes,
|
|
527
|
-
),
|
|
551
|
+
index=index,
|
|
552
|
+
columns=columns,
|
|
528
553
|
)
|
|
529
554
|
|
|
530
|
-
return df, DataFrameMetadata.from_data(
|
|
555
|
+
return df, DataFrameMetadata.from_data(
|
|
556
|
+
headers=full_headers,
|
|
557
|
+
execution_response=execution_response,
|
|
558
|
+
primary_labels_from_index=primary_labels_from_index,
|
|
559
|
+
primary_labels_from_columns=primary_labels_from_columns,
|
|
560
|
+
)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gooddata-pandas
|
|
3
|
-
Version: 1.18.
|
|
3
|
+
Version: 1.18.2.dev2
|
|
4
4
|
Summary: GoodData Cloud to pandas
|
|
5
5
|
Author: GoodData
|
|
6
6
|
Author-email: support@gooddata.com
|
|
7
7
|
License: MIT
|
|
8
|
-
Project-URL: Documentation, https://gooddata-pandas.readthedocs.io/en/v1.18.
|
|
8
|
+
Project-URL: Documentation, https://gooddata-pandas.readthedocs.io/en/v1.18.2.dev2
|
|
9
9
|
Project-URL: Source, https://github.com/gooddata/gooddata-python-sdk
|
|
10
10
|
Keywords: gooddata,pandas,series,data,frame,data_frame,analytics,headless,business,intelligence,headless-bi,cloud,native,semantic,layer,sql,metrics
|
|
11
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -22,7 +22,7 @@ Classifier: Typing :: Typed
|
|
|
22
22
|
Requires-Python: >=3.8.0
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE.txt
|
|
25
|
-
Requires-Dist: gooddata-sdk ~=1.18.
|
|
25
|
+
Requires-Dist: gooddata-sdk ~=1.18.2.dev2
|
|
26
26
|
Requires-Dist: pandas <2.0.0,>=1.0.0
|
|
27
27
|
|
|
28
28
|
# GoodData Pandas
|
|
@@ -4,11 +4,11 @@ gooddata_pandas/data_access.py,sha256=X8NKYtwWKFEfXvgrUbybuQmg1cub5pAhFtDCFMyzff
|
|
|
4
4
|
gooddata_pandas/dataframe.py,sha256=ryKKhiZAY6vi-uuRB-Oar60X3ARo8EAow5P4Bq1ZcJk,13413
|
|
5
5
|
gooddata_pandas/good_pandas.py,sha256=ePEm2Lmeiftz5td0BLC71q7my5Aj8aABn3xV0myRmqI,3444
|
|
6
6
|
gooddata_pandas/py.typed,sha256=u_MS29sadlaIqGRPYFjWml5u0gQnoQfvbsf9pu3TZJU,94
|
|
7
|
-
gooddata_pandas/result_convertor.py,sha256=
|
|
7
|
+
gooddata_pandas/result_convertor.py,sha256=6k9-Z6Jgtej2yPcR2iftKd2c6e8OwSEDkiil2o-zjP0,25892
|
|
8
8
|
gooddata_pandas/series.py,sha256=wTvJR_I0FUteyxo4RwHzP20eU7rei0dP8ZdqfrLbf5c,5759
|
|
9
9
|
gooddata_pandas/utils.py,sha256=PpkB6oWacRxYY9S-RbEZm9Jdblo4bgAzrmHzV9MlMPQ,7223
|
|
10
|
-
gooddata_pandas-1.18.
|
|
11
|
-
gooddata_pandas-1.18.
|
|
12
|
-
gooddata_pandas-1.18.
|
|
13
|
-
gooddata_pandas-1.18.
|
|
14
|
-
gooddata_pandas-1.18.
|
|
10
|
+
gooddata_pandas-1.18.2.dev2.dist-info/LICENSE.txt,sha256=CTs8U6T7MmKBKFFiQYARwgCfWgUzdosq01DI298WFiY,77209
|
|
11
|
+
gooddata_pandas-1.18.2.dev2.dist-info/METADATA,sha256=qixumufPBr3HVTZQ2AWAiw7Um_J3Pp5AKw2KHWVXQs0,2842
|
|
12
|
+
gooddata_pandas-1.18.2.dev2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
13
|
+
gooddata_pandas-1.18.2.dev2.dist-info/top_level.txt,sha256=B7K_WFxlxplJbEbv5Mf0YhX74dbOpTPgDX-W6I7CssI,16
|
|
14
|
+
gooddata_pandas-1.18.2.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|