Skip to content
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

Favor OrderedSet().as_list() #447

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion great_tables/_gt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@ def from_data(cls, data, rowname_col: str | None = None, groupname_col: str | No
row_info = [RowInfo(*i) for i in zip(row_indices, group_id, row_names)]

# create groups, and ensure they're ordered by first observed
group_names = list(OrderedSet(row.group_id for row in row_info if row.group_id is not None))
group_names = OrderedSet(
row.group_id for row in row_info if row.group_id is not None
).as_list()
group_rows = GroupRows(data, group_key=groupname_col).reorder(group_names)

return cls(row_info, group_rows)
Expand Down
4 changes: 2 additions & 2 deletions great_tables/_spanners.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ def tab_spanner(

# get column names associated with selected spanners ----
_vars = [span.vars for span in self._spanners if span.spanner_id in spanner_ids]
spanner_column_names = OrderedSet(itertools.chain(*_vars))
spanner_column_names = OrderedSet(itertools.chain(*_vars)).as_list()

column_names = list(OrderedSet([*selected_column_names, *spanner_column_names]))
column_names = OrderedSet([*selected_column_names, *spanner_column_names]).as_list()
# combine columns names and those from spanners ----

# get spanner level ----
Expand Down