gooddata-pandas 1.18.1__tar.gz → 1.18.2.dev2__tar.gz

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.

Files changed (21) hide show
  1. {gooddata_pandas-1.18.1/gooddata_pandas.egg-info → gooddata_pandas-1.18.2.dev2}/PKG-INFO +3 -3
  2. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/result_convertor.py +53 -23
  3. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2/gooddata_pandas.egg-info}/PKG-INFO +3 -3
  4. gooddata_pandas-1.18.2.dev2/gooddata_pandas.egg-info/requires.txt +2 -0
  5. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/setup.py +3 -3
  6. gooddata_pandas-1.18.1/gooddata_pandas.egg-info/requires.txt +0 -2
  7. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/LICENSE.txt +0 -0
  8. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/MANIFEST.in +0 -0
  9. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/README.md +0 -0
  10. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/__init__.py +0 -0
  11. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/_version.py +0 -0
  12. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/data_access.py +0 -0
  13. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/dataframe.py +0 -0
  14. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/good_pandas.py +0 -0
  15. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/py.typed +0 -0
  16. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/series.py +0 -0
  17. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas/utils.py +0 -0
  18. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas.egg-info/SOURCES.txt +0 -0
  19. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas.egg-info/dependency_links.txt +0 -0
  20. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/gooddata_pandas.egg-info/top_level.txt +0 -0
  21. {gooddata_pandas-1.18.1 → gooddata_pandas-1.18.2.dev2}/setup.cfg +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gooddata-pandas
3
- Version: 1.18.1
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.1
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.1
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
@@ -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 = header["attributeHeader"]["primaryLabelValue"]
351
+ label = primary_label_value
341
352
  else:
342
- label = header["attributeHeader"]["labelValue"]
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, or None if the headers are empty.
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=_headers_to_index(
513
- dim_idx=0,
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(headers=full_headers, execution_response=execution_response)
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.1
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.1
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.1
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
@@ -0,0 +1,2 @@
1
+ gooddata-sdk~=1.18.2.dev2
2
+ pandas<2.0.0,>=1.0.0
@@ -7,7 +7,7 @@ this_directory = Path(__file__).parent
7
7
  long_description = (this_directory / "README.md").read_text(encoding="utf-8")
8
8
 
9
9
  REQUIRES = [
10
- "gooddata-sdk~=1.18.1",
10
+ "gooddata-sdk~=1.18.2.dev2",
11
11
  "pandas>=1.0.0,<2.0.0",
12
12
  ]
13
13
 
@@ -16,7 +16,7 @@ setup(
16
16
  description="GoodData Cloud to pandas",
17
17
  long_description=long_description,
18
18
  long_description_content_type="text/markdown",
19
- version="1.18.1",
19
+ version="1.18.2.dev2",
20
20
  author="GoodData",
21
21
  author_email="support@gooddata.com",
22
22
  license="MIT",
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(exclude=["tests*"]),
27
27
  python_requires=">=3.8.0",
28
28
  project_urls={
29
- "Documentation": "https://gooddata-pandas.readthedocs.io/en/v1.18.1",
29
+ "Documentation": "https://gooddata-pandas.readthedocs.io/en/v1.18.2.dev2",
30
30
  "Source": "https://github.com/gooddata/gooddata-python-sdk",
31
31
  },
32
32
  classifiers=[
@@ -1,2 +0,0 @@
1
- gooddata-sdk~=1.18.1
2
- pandas<2.0.0,>=1.0.0