dataframe-textual 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
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.
- dataframe_textual/data_frame_table.py +2 -4
- dataframe_textual/table_screen.py +29 -24
- {dataframe_textual-0.3.0.dist-info → dataframe_textual-0.3.1.dist-info}/METADATA +1 -1
- {dataframe_textual-0.3.0.dist-info → dataframe_textual-0.3.1.dist-info}/RECORD +7 -7
- {dataframe_textual-0.3.0.dist-info → dataframe_textual-0.3.1.dist-info}/WHEEL +0 -0
- {dataframe_textual-0.3.0.dist-info → dataframe_textual-0.3.1.dist-info}/entry_points.txt +0 -0
- {dataframe_textual-0.3.0.dist-info → dataframe_textual-0.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -549,7 +549,7 @@ class DataFrameTable(DataTable):
|
|
|
549
549
|
return
|
|
550
550
|
|
|
551
551
|
# Push the modal screen
|
|
552
|
-
self.app.push_screen(RowDetailScreen(row_idx, self
|
|
552
|
+
self.app.push_screen(RowDetailScreen(row_idx, self))
|
|
553
553
|
|
|
554
554
|
def _show_frequency(self) -> None:
|
|
555
555
|
"""Show frequency distribution for the current column."""
|
|
@@ -558,9 +558,7 @@ class DataFrameTable(DataTable):
|
|
|
558
558
|
return
|
|
559
559
|
|
|
560
560
|
# Push the frequency modal screen
|
|
561
|
-
self.app.push_screen(
|
|
562
|
-
FrequencyScreen(col_idx, self.df.filter(self.visible_rows))
|
|
563
|
-
)
|
|
561
|
+
self.app.push_screen(FrequencyScreen(col_idx, self))
|
|
564
562
|
|
|
565
563
|
def _open_freeze_screen(self) -> None:
|
|
566
564
|
"""Open the freeze screen to set fixed rows and columns."""
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"""Modal screens for displaying data in tables (row details and frequency)."""
|
|
2
2
|
|
|
3
|
-
from typing import Any
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from .data_frame_table import DataFrameTable
|
|
4
7
|
|
|
5
8
|
import polars as pl
|
|
6
9
|
from rich.text import Text
|
|
@@ -33,14 +36,14 @@ class TableScreen(ModalScreen):
|
|
|
33
36
|
}
|
|
34
37
|
"""
|
|
35
38
|
|
|
36
|
-
def __init__(self,
|
|
39
|
+
def __init__(self, dftable: DataFrameTable):
|
|
37
40
|
super().__init__()
|
|
38
|
-
self.df = df
|
|
39
|
-
self.
|
|
41
|
+
self.df: pl.DataFrame = dftable.df # Polars DataFrame
|
|
42
|
+
self.dftable = dftable # DataFrameTable
|
|
40
43
|
|
|
41
44
|
def compose(self) -> ComposeResult:
|
|
42
45
|
"""Create the table. Must be overridden by subclasses."""
|
|
43
|
-
self.table = DataTable(zebra_stripes=True
|
|
46
|
+
self.table = DataTable(zebra_stripes=True)
|
|
44
47
|
yield self.table
|
|
45
48
|
|
|
46
49
|
def on_key(self, event):
|
|
@@ -87,27 +90,26 @@ class TableScreen(ModalScreen):
|
|
|
87
90
|
expr = pl.col(col_name) == col_value
|
|
88
91
|
value_display = f"[on $primary]{col_value}[/]"
|
|
89
92
|
|
|
90
|
-
app = self.app
|
|
91
93
|
matched_indices = set(
|
|
92
|
-
|
|
94
|
+
self.dftable.df.with_row_index("__rid__").filter(expr)["__rid__"].to_list()
|
|
93
95
|
)
|
|
94
96
|
|
|
95
97
|
# Apply the action
|
|
96
98
|
if action == "filter":
|
|
97
99
|
# Update visible_rows to reflect the filter
|
|
98
|
-
for i in range(len(
|
|
99
|
-
|
|
100
|
+
for i in range(len(self.dftable.visible_rows)):
|
|
101
|
+
self.dftable.visible_rows[i] = i in matched_indices
|
|
100
102
|
title = "Filter"
|
|
101
103
|
message = f"Filtered by [on $primary]{col_name}[/] = {value_display}"
|
|
102
104
|
else: # action == "highlight"
|
|
103
105
|
# Update selected_rows to reflect the highlights
|
|
104
|
-
for i in range(len(
|
|
105
|
-
|
|
106
|
+
for i in range(len(self.dftable.selected_rows)):
|
|
107
|
+
self.dftable.selected_rows[i] = i in matched_indices
|
|
106
108
|
title = "Highlight"
|
|
107
109
|
message = f"Highlighted [on $primary]{col_name}[/] = {value_display}"
|
|
108
110
|
|
|
109
111
|
# Recreate the table display with updated data in the main app
|
|
110
|
-
|
|
112
|
+
self.dftable._setup_table()
|
|
111
113
|
|
|
112
114
|
# Dismiss the frequency screen
|
|
113
115
|
self.app.pop_screen()
|
|
@@ -120,8 +122,8 @@ class RowDetailScreen(TableScreen):
|
|
|
120
122
|
|
|
121
123
|
CSS = TableScreen.DEFAULT_CSS.replace("TableScreen", "RowDetailScreen")
|
|
122
124
|
|
|
123
|
-
def __init__(self, row_idx: int,
|
|
124
|
-
super().__init__(
|
|
125
|
+
def __init__(self, row_idx: int, dftable):
|
|
126
|
+
super().__init__(dftable)
|
|
125
127
|
self.row_idx = row_idx
|
|
126
128
|
|
|
127
129
|
def on_mount(self) -> None:
|
|
@@ -169,8 +171,8 @@ class FrequencyScreen(TableScreen):
|
|
|
169
171
|
|
|
170
172
|
CSS = TableScreen.DEFAULT_CSS.replace("TableScreen", "FrequencyScreen")
|
|
171
173
|
|
|
172
|
-
def __init__(self, col_idx: int,
|
|
173
|
-
super().__init__(
|
|
174
|
+
def __init__(self, col_idx: int, dftable):
|
|
175
|
+
super().__init__(dftable)
|
|
174
176
|
self.col_idx = col_idx
|
|
175
177
|
self.sorted_columns = {
|
|
176
178
|
1: True, # Count
|
|
@@ -283,14 +285,17 @@ class FrequencyScreen(TableScreen):
|
|
|
283
285
|
def key_fun(freq_col):
|
|
284
286
|
col_value = freq_col.plain
|
|
285
287
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
288
|
+
try:
|
|
289
|
+
if col_dtype == "Int64":
|
|
290
|
+
return int(col_value)
|
|
291
|
+
elif col_dtype == "Float64":
|
|
292
|
+
return float(col_value)
|
|
293
|
+
elif col_dtype == "Boolean":
|
|
294
|
+
return BOOLS[col_value]
|
|
295
|
+
else:
|
|
296
|
+
return col_value
|
|
297
|
+
except ValueError:
|
|
298
|
+
return 0
|
|
294
299
|
|
|
295
300
|
# Sort the table
|
|
296
301
|
freq_table.sort(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataframe-textual
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Interactive CSV/Excel viewer for the terminal (Textual TUI)
|
|
5
5
|
Project-URL: Homepage, https://github.com/need47/dataframe-textual
|
|
6
6
|
Project-URL: Repository, https://github.com/need47/dataframe-textual.git
|
|
@@ -2,12 +2,12 @@ dataframe_textual/__init__.py,sha256=uzB3bjlbm8JbsjxEgwqvPcYERktm3F9d9Op_6cWJ1sk
|
|
|
2
2
|
dataframe_textual/__main__.py,sha256=LPLyZcv4hAFfF3hUt1S2dtZOqaAZnlguicgwiDrtXgk,1349
|
|
3
3
|
dataframe_textual/common.py,sha256=3zzhI__F_hoOFDRe-wt-oTfMDFik1ohraIa6rXcVit8,6357
|
|
4
4
|
dataframe_textual/data_frame_help_panel.py,sha256=SQ2lulb1SPxItR9tMvIgOzzeCcW9SB1rRojAcwZ7Vis,2730
|
|
5
|
-
dataframe_textual/data_frame_table.py,sha256=
|
|
5
|
+
dataframe_textual/data_frame_table.py,sha256=8CCTwhi0cYPr9yEuMlv76rzPT48PzxyjsCIP2P3g3_c,50025
|
|
6
6
|
dataframe_textual/data_frame_viewer.py,sha256=BP-pCYIG5bEDFkUmUyA3sxWc3z1zI_viClDZlT-s_uE,11715
|
|
7
|
-
dataframe_textual/table_screen.py,sha256=
|
|
7
|
+
dataframe_textual/table_screen.py,sha256=elY0gBdc0PQlh82N7lu3FHeVoFprqd-8iUBVvfSdah0,11015
|
|
8
8
|
dataframe_textual/yes_no_screen.py,sha256=z7MEVTMepFuGWFIthhQlAT3m69D6lgIl4tb2_oJAWWQ,13207
|
|
9
|
-
dataframe_textual-0.3.
|
|
10
|
-
dataframe_textual-0.3.
|
|
11
|
-
dataframe_textual-0.3.
|
|
12
|
-
dataframe_textual-0.3.
|
|
13
|
-
dataframe_textual-0.3.
|
|
9
|
+
dataframe_textual-0.3.1.dist-info/METADATA,sha256=nmpsgfqdd5E9RAe3rMwI_qkX3V_n_k_bVFP-DX9bAzY,17109
|
|
10
|
+
dataframe_textual-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
dataframe_textual-0.3.1.dist-info/entry_points.txt,sha256=FkXDHVYYtGud6F2Jm2X9OMFAuFrSflNfgcNP5c2469M,70
|
|
12
|
+
dataframe_textual-0.3.1.dist-info/licenses/LICENSE,sha256=AVTg0gk1X-LHI-nnHlAMDQetrwuDZK4eypgSMDO46Yc,1069
|
|
13
|
+
dataframe_textual-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|