Skip to content

Commit 80d32bd

Browse files
committed
Use filter() + row_number() to slice tbl tail
1 parent 0eb4d41 commit 80d32bd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

pointblank/validate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ def _generate_display_table(
543543
# - get the row numbers for the table
544544
# - convert the table to a Polars or Pandas DF
545545
if ibis_tbl:
546+
import ibis
547+
546548
# Get the Schema of the table
547549
tbl_schema = Schema(tbl=data)
548550

@@ -559,12 +561,15 @@ def _generate_display_table(
559561
row_number_list = range(1, n_rows + 1)
560562
else:
561563
# Get the first and last n rows of the table
564+
# data_tail = covid_stats.filter([ibis.row_number() >= (n_rows - n_tail), ibis.row_number() <= n_rows])
562565
data_head = data.head(n_head)
563-
row_numbers_head = range(1, n_head + 1)
564-
data_tail = data[(n_rows - n_tail) : n_rows]
565-
row_numbers_tail = range(n_rows - n_tail + 1, n_rows + 1)
566+
data_tail = data.filter(
567+
[ibis.row_number() >= (n_rows - n_tail), ibis.row_number() <= n_rows]
568+
)
566569
data_subset = data_head.union(data_tail)
567570

571+
row_numbers_head = range(1, n_head + 1)
572+
row_numbers_tail = range(n_rows - n_tail + 1, n_rows + 1)
568573
if row_number_list is None:
569574
row_number_list = list(row_numbers_head) + list(row_numbers_tail)
570575

0 commit comments

Comments
 (0)