-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React-Table transformer #170
Conversation
…d CSV transformers to pivot any dimension and to transpose the data frame
fireant/slicer/queries/database.py
Outdated
if 1 < pd.isnull(df).sum(): | ||
return df.fillna(NULL_VALUE, limit=1) | ||
return df | ||
if offset < pd.isnull(df).sum(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have a comment on this and/or a docstring for offset. Right now I'm not really sure I understood this logic.
|
||
|
||
class Widget: | ||
def __init__(self, *items: Metric): | ||
def __init__(self, *items: Union[Metric, Operation]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are using *arg then I believe the typing annotation should be List[Union[Metric, Operation]]. Same applies for all usages of *arg in this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fireant/utils.py
Outdated
@@ -13,6 +13,34 @@ def deep_get(d, keys, default=None): | |||
d_level = d_level[key] | |||
return d_level | |||
|
|||
|
|||
def setdeepattr(d, key, value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming here and in the function below could be improved. Set deep attribute is not really meaningful. Docstrings are welcome as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add some docs. The naming is meant to extend setattr
which is a built in func.
fireant/utils.py
Outdated
@@ -23,6 +51,12 @@ def slice_first(item): | |||
return item | |||
|
|||
|
|||
a = 'a' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this always 'a'? What's the point of those ternary ifs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like dead code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what this is. going to remove it
fireant/slicer/widgets/reacttable.py
Outdated
@staticmethod | ||
def transform_data(data_frame, item_map, dimension_display_values): | ||
""" | ||
WRITEME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forgot to write a docstring for this and other occurrences of WRITEME?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@@ -33,7 +33,7 @@ def test_single_metric(self): | |||
expected = single_metric_df.copy()[[fm('votes')]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any tests specifically for the react table transformer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course, in fireant/tests/slicer/widgets/test_reacttable.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, github didn't load the diff as the file was too large.
fireant/slicer/widgets/reacttable.py
Outdated
row = {} | ||
for key, value in zip(data_frame.index.names, index): | ||
if key is None: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some inline comments in these complex functions would be useful, otherwise it is hard to follow.
Added a react-table transformer and changed pivot behavior of the Pandas and CSV transformers to pivot any dimension and to transpose the data frame.
These transformers accept two arguments:
pivot: List<Dimension>
andtranspose: bool
With pivoted dimensions, the tables will render dimension values across columns instead of rows. When transpose is true, the columns and rows will be swapped.