You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/01/28 05:22:53 UTC
[GitHub] [incubator-superset] john-bodley opened a new pull request #9031:
[fix] Pivot table metric ordering
john-bodley opened a new pull request #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031
### CATEGORY
Choose one
- [x] Bug Fix
- [ ] Enhancement (new features, refinement)
- [ ] Refactor
- [ ] Add tests
- [ ] Build / Development Environment
- [ ] Documentation
### SUMMARY
The pivot-table visualization doesn't preserve metric ordering which is due to the `pandas.pivot_table` function. The Pandas suggestion (per [here](https://github.com/pandas-dev/pandas/issues/17041#issuecomment-489434926)) is to simply re-index the data.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TEST PLAN
Tested locally and confirmed that the metric ordering is preserved. Note there are currently no unit tests for the pivot-table visualization type.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Changes UI
- [ ] Requires DB Migration.
- [ ] Confirm DB Migration upgrade and downgrade tested.
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
### REVIEWERS
to: @etr2460 @michellethomas @mistercrunch
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] john-bodley commented on a change in pull
request #9031: [fix] Pivot table metric ordering
Posted by GitBox <gi...@apache.org>.
john-bodley commented on a change in pull request #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031#discussion_r371614850
##########
File path: superset/viz.py
##########
@@ -676,7 +676,7 @@ def query_obj(self):
)
if not metrics:
raise Exception(_("Please choose at least one metric"))
- if any(v in groupby for v in columns) or any(v in columns for v in groupby):
+ if set(groupby) & set(columns):
Review comment:
This is the same logic but in a more condensed form.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-io commented on issue #9031: [fix]
Pivot table metric ordering
Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031#issuecomment-580018865
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=h1) Report
> Merging [#9031](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-superset/commit/d0aab05e79cd52812b5ae8dea8b26ce2f5a476ed?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.
[![Impacted file tree graph](https://codecov.io/gh/apache/incubator-superset/pull/9031/graphs/tree.svg?width=650&token=KsB0fHcx6l&height=150&src=pr)](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #9031 +/- ##
=======================================
Coverage 59.43% 59.43%
=======================================
Files 369 369
Lines 11743 11743
Branches 2884 2884
=======================================
Hits 6980 6980
Misses 4584 4584
Partials 179 179
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=footer). Last update [d0aab05...e922f72](https://codecov.io/gh/apache/incubator-superset/pull/9031?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] john-bodley commented on issue #9031: [fix]
Pivot table metric ordering
Posted by GitBox <gi...@apache.org>.
john-bodley commented on issue #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031#issuecomment-579972717
@mistercrunch the reindex logic doesn't work if the resulting `pandas.DataFrame` is multi-faceted, i.e., has a `pandas.MultiIndex`. The fix is merely to use the `[]` operator for selecting the columns per [here](https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#basics).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] john-bodley commented on a change in pull
request #9031: [fix] Pivot table metric ordering
Posted by GitBox <gi...@apache.org>.
john-bodley commented on a change in pull request #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031#discussion_r371614993
##########
File path: superset/viz.py
##########
@@ -694,15 +694,14 @@ def get_data(self, df: pd.DataFrame) -> VizData:
columns = self.form_data.get("columns")
if self.form_data.get("transpose_pivot"):
groupby, columns = columns, groupby
+ metrics = [utils.get_metric_name(m) for m in self.form_data["metrics"]]
df = df.pivot_table(
index=groupby,
columns=columns,
- values=[
- utils.get_metric_name(m) for m in self.form_data.get("metrics", [])
Review comment:
There's no need to do `self.form_data.get("metrics", [])` since in the `query_obj` method we've already verified there exists at least one metric.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] john-bodley merged pull request #9031: [fix]
Pivot table metric ordering
Posted by GitBox <gi...@apache.org>.
john-bodley merged pull request #9031: [fix] Pivot table metric ordering
URL: https://github.com/apache/incubator-superset/pull/9031
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org