dataframe-textual 2.38.0__tar.gz → 2.40.1__tar.gz

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.
Files changed (19) hide show
  1. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/PKG-INFO +43 -27
  2. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/README.md +42 -26
  3. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/pyproject.toml +1 -1
  4. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/common.py +44 -2
  5. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/data_frame_table.py +71 -12
  6. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/table_screen.py +62 -4
  7. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/yes_no_screen.py +3 -2
  8. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/uv.lock +1 -1
  9. dataframe_textual-2.38.0/xbk/common.py_w_compute_error +0 -940
  10. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/.gitignore +0 -0
  11. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/LICENSE +0 -0
  12. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/main.py +0 -0
  13. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/__init__.py +0 -0
  14. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/__main__.py +0 -0
  15. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/data_frame_help_panel.py +0 -0
  16. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/data_frame_viewer.py +0 -0
  17. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/file_picker_screen.py +0 -0
  18. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/loading_screen.py +0 -0
  19. {dataframe_textual-2.38.0 → dataframe_textual-2.40.1}/src/dataframe_textual/theme_screen.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataframe-textual
3
- Version: 2.38.0
3
+ Version: 2.40.1
4
4
  Summary: Interactive terminal viewer/editor for tabular data
5
5
  Project-URL: Homepage, https://github.com/need47/dataframe-textual
6
6
  Project-URL: Repository, https://github.com/need47/dataframe-textual.git
@@ -54,6 +54,7 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet]
54
54
 
55
55
  ### Data Manipulation
56
56
  - 📝 **Data Editing** - Edit cells, delete rows, remove columns, and explode columns
57
+ - 🧹 **Duplicate Removal** - Remove duplicate rows while keeping the first occurrence
57
58
  - 🔍 **Search & Filter** - Find values, highlight matches, and filter selected rows
58
59
  - ↔️ **Column/Row Reordering** - Move columns and rows with simple keyboard shortcuts
59
60
  - 📈 **Sorting & Statistics** - Multi-column sorting, frequency distribution, and histogram analysis
@@ -310,7 +311,8 @@ dv data.csv -o data.parquet
310
311
 
311
312
  | Key | Action |
312
313
  | ---------------- | -------------------------------------------------- |
313
- | `Enter` | Record view of current row transposed |
314
+ | `Enter` | Show details for the current row |
315
+ | `Tab` | Show details for the current cell |
314
316
  | `F` | Show frequency distribution for current column |
315
317
  | `i` | Show histogram for current column |
316
318
  | `I` | Show histogram for current column with custom bins |
@@ -345,6 +347,7 @@ dv data.csv -o data.parquet
345
347
  | `Ctrl+X` | Delete current row and all those above |
346
348
  | `d` | Duplicate current column |
347
349
  | `D` | Duplicate current row |
350
+ | `=` | Remove duplicate rows (keep first occurrence) |
348
351
  | `o` | Explode current list column into multiple rows |
349
352
  | `O` | Explode current string column by delimiter into multiple rows |
350
353
 
@@ -444,9 +447,21 @@ Useful for examining wide datasets where columns don't fit well on screen.
444
447
  - Press `}` to move to the next row
445
448
  - Press `F` to show the frequency table for the selected column
446
449
  - Press `s` to show the statistics table for the selected column
450
+ - Press `Tab` to open a cell-detail modal for the selected field
447
451
  - Press `q` or `Escape` to close the modal
448
452
 
449
- ### 3. Row Selection
453
+ ### 3. Cell Detail View
454
+
455
+ Press `Tab` in the main table to inspect the current cell in its own modal.
456
+
457
+ You can also press `Tab` from the row-detail modal to drill into the selected field.
458
+
459
+ - Scalar values are shown directly
460
+ - String values are split into multiple rows using `|` by default
461
+ - Lists and structs are expanded into a readable table layout
462
+ - Press `q` or `Escape` to close the modal
463
+
464
+ ### 4. Row Selection
450
465
 
451
466
  The application provides multiple modes for selecting rows (marks it for filtering or viewing):
452
467
 
@@ -472,7 +487,7 @@ These options work with plain text searches. Use Polars regex patterns in expres
472
487
  - Type-aware matching automatically converts values. Resort to string comparison if conversion fails
473
488
  - Use `u` to undo any search or filter
474
489
 
475
- ### 4. Find & Replace
490
+ ### 5. Find & Replace
476
491
  Find by value/expression and highlight matching cells:
477
492
  - `/` - Find cursor value across all columns (global search)
478
493
  - `?` - Open dialog to search all columns with expression (global search)
@@ -506,7 +521,7 @@ When you press `r` or `R`, enter:
506
521
  - Use `Match Whole` to avoid partial replacements
507
522
  - Support undo (`u`)
508
523
 
509
- ### 5. View vs. Filter
524
+ ### 6. View vs. Filter
510
525
 
511
526
  Both operations show selected rows but with fundamentally different effects:
512
527
 
@@ -526,7 +541,7 @@ Both operations show selected rows but with fundamentally different effects:
526
541
  - If currently there are no selected rows and no matching cells, the `v` (View) and `"` (Filter) will use cursor value for search.
527
542
  - Both support full undo with `u`.
528
543
 
529
- ### 6. [Polars Expressions](https://docs.pola.rs/api/python/stable/reference/expressions/index.html)
544
+ ### 7. [Polars Expressions](https://docs.pola.rs/api/python/stable/reference/expressions/index.html)
530
545
 
531
546
  Complex values or filters can be specified via Polars expressions, with the following adaptions for convenience:
532
547
 
@@ -583,14 +598,14 @@ Complex values or filters can be specified via Polars expressions, with the foll
583
598
  - Use column names that match exactly (case-sensitive)
584
599
  - Use parentheses to clarify complex expressions: `($a & $b) | ($c & $d)`
585
600
 
586
- ### 7. Sorting
601
+ ### 8. Sorting
587
602
 
588
603
  - Press `[` to sort current column ascending
589
604
  - Press `]` to sort current column descending
590
605
  - Multi-column sorting supported (press multiple times on different columns)
591
606
  - Press same key twice to remove the column from sorting
592
607
 
593
- ### 8. Dataframe & Column Metadata
608
+ ### 9. Dataframe & Column Metadata
594
609
 
595
610
  View quick metadata about your dataframe and columns to understand their structure and content.
596
611
 
@@ -611,7 +626,7 @@ View quick metadata about your dataframe and columns to understand their structu
611
626
  **In Metadata Modals**:
612
627
  - Press `q` or `Escape` to close
613
628
 
614
- ### 9. Frequency Distribution
629
+ ### 10. Frequency Distribution
615
630
 
616
631
  Press `F` to see value distributions of the current column. The modal shows:
617
632
  - Value, Count, Percentage, Histogram
@@ -633,7 +648,7 @@ This is useful for:
633
648
  - Identifying rare or common values
634
649
  - Finding the most/least frequent entries
635
650
 
636
- ### 10. Column & Dataframe Statistics
651
+ ### 11. Column & Dataframe Statistics
637
652
 
638
653
  Show summary statistics (count, null count, mean, median, std, min, max, etc.) using Polars' `describe()` method.
639
654
  - `s` for the current column
@@ -651,7 +666,7 @@ This is useful for:
651
666
  - Quick statistical summaries without external tools
652
667
  - Comparing statistics across columns
653
668
 
654
- ### 11. Editing
669
+ ### 12. Editing
655
670
 
656
671
  **Edit Cell** (`e` or **Double-click**):
657
672
  - Opens modal for editing current cell
@@ -699,7 +714,7 @@ This is useful for:
699
714
  - `h` - Temporarily hide current column (data preserved)
700
715
  - `H` - Restore all hidden columns
701
716
 
702
- ### 12. Column & Row Reordering
717
+ ### 13. Column & Row Reordering
703
718
 
704
719
  **Move Columns**: `Shift+←` and `Shift+→`
705
720
  - Swaps adjacent columns
@@ -709,12 +724,12 @@ This is useful for:
709
724
  - Swaps adjacent rows
710
725
  - Reorder is preserved when saving
711
726
 
712
- ### 13. Freeze Rows and Columns
727
+ ### 14. Freeze Rows and Columns
713
728
 
714
- Press `z` to open the dialog:
729
+ Press `f` to open the dialog:
715
730
  - Enter number of fixed rows and/or columns to keep top rows/columns visible while scrolling
716
731
 
717
- ### 14. Thousand Separator Toggle
732
+ ### 15. Thousand Separator Toggle
718
733
 
719
734
  Press `,` to toggle thousand separator formatting for numeric data:
720
735
  - Applies to **integer** and **float** columns
@@ -724,11 +739,11 @@ Press `,` to toggle thousand separator formatting for numeric data:
724
739
  - Display-only: does not modify underlying data in the dataframe
725
740
  - State persists during the session
726
741
 
727
- ### 15. Save File
742
+ ### 16. Save File
728
743
 
729
744
  Press `Ctrl+S` to save filtered, edited, or sorted data back to file. The output format is automatically determined by the file extension, making it easy to convert between different formats (e.g., CSV to TSV).
730
745
 
731
- ### 16. Undo/Redo/Reset
746
+ ### 17. Undo/Redo/Reset
732
747
 
733
748
  **Undo** (`u`):
734
749
  - Reverts last action with full state restoration
@@ -746,7 +761,7 @@ Press `Ctrl+S` to save filtered, edited, or sorted data back to file. The output
746
761
  - Clears all edits, deletions, selections, filters, and sorts
747
762
  - Useful for starting fresh without reloading the file
748
763
 
749
- ### 17. Column Type Conversion
764
+ ### 18. Column Type Conversion
750
765
 
751
766
  Press the type conversion keys to instantly cast the current column to a different data type:
752
767
 
@@ -763,14 +778,14 @@ Press the type conversion keys to instantly cast the current column to a differe
763
778
 
764
779
  **Note**: Type conversion attempts to preserve data where possible. Conversions may lose data (e.g., float to int rounding).
765
780
 
766
- ### 18. Cursor Type Cycling
781
+ ### 19. Cursor Type Cycling
767
782
 
768
783
  Press `K` to cycle through selection modes:
769
784
  1. **Cell mode**: Highlight individual cell (and its row/column headers)
770
785
  2. **Row mode**: Highlight entire row
771
786
  3. **Column mode**: Highlight entire column
772
787
 
773
- ### 19. SQL Interface
788
+ ### 20. SQL Interface
774
789
 
775
790
  The SQL interface provides two modes for querying your dataframe:
776
791
 
@@ -800,7 +815,7 @@ FROM self
800
815
  WHERE `product id` = 7
801
816
  ```
802
817
 
803
- ### 20. Clipboard Operations
818
+ ### 21. Clipboard Operations
804
819
 
805
820
  Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux.
806
821
 
@@ -811,7 +826,7 @@ Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux.
811
826
  - Press `Ctrl+R` to copy row values (delimited by tab)
812
827
  - Hold `Shift` to select with mouse
813
828
 
814
- ### 21. Link Column Creation
829
+ ### 22. Link Column Creation
815
830
 
816
831
  Press `@` to create a new column containing dynamically generated URLs using template.
817
832
 
@@ -833,16 +848,17 @@ The link template supports multiple placeholder types for maximum flexibility:
833
848
  - Use full undo (`u`) if template produces unexpected URLs
834
849
  - For complex multi-column URLs, use column names (`$name`) for clarity over positions (`$1`)
835
850
 
836
- ### 22. Tab Management
851
+ ### 23. Tab Management
837
852
 
838
853
  Manage multiple files and dataframes simultaneously with tabs.
839
854
 
840
855
  **Tab Operations:**
841
856
  - **`Ctrl+O`** - Open file in a new tab
842
- - **`>`** - Move to next tab
843
- - **`<`** - Move to previous tab
844
- - **`b`** - Cycle through tabs
845
- - **`B`** - Toggle tab bar visibility
857
+ - **`b`** - Go to the next tab
858
+ - **`B`** - Go to the previous tab
859
+ - **`space`** - Toggle the tab bar visibility
860
+ - **`>`** - Move the current tab right
861
+ - **`<`** - Move the current tab left
846
862
  - **`Double-click`** - Rename the tab
847
863
  - **`Ctrl+D`** - Duplicate current tab (creates a copy with same data and state)
848
864
  - **`Ctrl+T`** - Save current tab to file
@@ -15,6 +15,7 @@ A powerful, interactive terminal-based viewer/editor for CSV/TSV/Excel/[Parquet]
15
15
 
16
16
  ### Data Manipulation
17
17
  - 📝 **Data Editing** - Edit cells, delete rows, remove columns, and explode columns
18
+ - 🧹 **Duplicate Removal** - Remove duplicate rows while keeping the first occurrence
18
19
  - 🔍 **Search & Filter** - Find values, highlight matches, and filter selected rows
19
20
  - ↔️ **Column/Row Reordering** - Move columns and rows with simple keyboard shortcuts
20
21
  - 📈 **Sorting & Statistics** - Multi-column sorting, frequency distribution, and histogram analysis
@@ -271,7 +272,8 @@ dv data.csv -o data.parquet
271
272
 
272
273
  | Key | Action |
273
274
  | ---------------- | -------------------------------------------------- |
274
- | `Enter` | Record view of current row transposed |
275
+ | `Enter` | Show details for the current row |
276
+ | `Tab` | Show details for the current cell |
275
277
  | `F` | Show frequency distribution for current column |
276
278
  | `i` | Show histogram for current column |
277
279
  | `I` | Show histogram for current column with custom bins |
@@ -306,6 +308,7 @@ dv data.csv -o data.parquet
306
308
  | `Ctrl+X` | Delete current row and all those above |
307
309
  | `d` | Duplicate current column |
308
310
  | `D` | Duplicate current row |
311
+ | `=` | Remove duplicate rows (keep first occurrence) |
309
312
  | `o` | Explode current list column into multiple rows |
310
313
  | `O` | Explode current string column by delimiter into multiple rows |
311
314
 
@@ -405,9 +408,21 @@ Useful for examining wide datasets where columns don't fit well on screen.
405
408
  - Press `}` to move to the next row
406
409
  - Press `F` to show the frequency table for the selected column
407
410
  - Press `s` to show the statistics table for the selected column
411
+ - Press `Tab` to open a cell-detail modal for the selected field
408
412
  - Press `q` or `Escape` to close the modal
409
413
 
410
- ### 3. Row Selection
414
+ ### 3. Cell Detail View
415
+
416
+ Press `Tab` in the main table to inspect the current cell in its own modal.
417
+
418
+ You can also press `Tab` from the row-detail modal to drill into the selected field.
419
+
420
+ - Scalar values are shown directly
421
+ - String values are split into multiple rows using `|` by default
422
+ - Lists and structs are expanded into a readable table layout
423
+ - Press `q` or `Escape` to close the modal
424
+
425
+ ### 4. Row Selection
411
426
 
412
427
  The application provides multiple modes for selecting rows (marks it for filtering or viewing):
413
428
 
@@ -433,7 +448,7 @@ These options work with plain text searches. Use Polars regex patterns in expres
433
448
  - Type-aware matching automatically converts values. Resort to string comparison if conversion fails
434
449
  - Use `u` to undo any search or filter
435
450
 
436
- ### 4. Find & Replace
451
+ ### 5. Find & Replace
437
452
  Find by value/expression and highlight matching cells:
438
453
  - `/` - Find cursor value across all columns (global search)
439
454
  - `?` - Open dialog to search all columns with expression (global search)
@@ -467,7 +482,7 @@ When you press `r` or `R`, enter:
467
482
  - Use `Match Whole` to avoid partial replacements
468
483
  - Support undo (`u`)
469
484
 
470
- ### 5. View vs. Filter
485
+ ### 6. View vs. Filter
471
486
 
472
487
  Both operations show selected rows but with fundamentally different effects:
473
488
 
@@ -487,7 +502,7 @@ Both operations show selected rows but with fundamentally different effects:
487
502
  - If currently there are no selected rows and no matching cells, the `v` (View) and `"` (Filter) will use cursor value for search.
488
503
  - Both support full undo with `u`.
489
504
 
490
- ### 6. [Polars Expressions](https://docs.pola.rs/api/python/stable/reference/expressions/index.html)
505
+ ### 7. [Polars Expressions](https://docs.pola.rs/api/python/stable/reference/expressions/index.html)
491
506
 
492
507
  Complex values or filters can be specified via Polars expressions, with the following adaptions for convenience:
493
508
 
@@ -544,14 +559,14 @@ Complex values or filters can be specified via Polars expressions, with the foll
544
559
  - Use column names that match exactly (case-sensitive)
545
560
  - Use parentheses to clarify complex expressions: `($a & $b) | ($c & $d)`
546
561
 
547
- ### 7. Sorting
562
+ ### 8. Sorting
548
563
 
549
564
  - Press `[` to sort current column ascending
550
565
  - Press `]` to sort current column descending
551
566
  - Multi-column sorting supported (press multiple times on different columns)
552
567
  - Press same key twice to remove the column from sorting
553
568
 
554
- ### 8. Dataframe & Column Metadata
569
+ ### 9. Dataframe & Column Metadata
555
570
 
556
571
  View quick metadata about your dataframe and columns to understand their structure and content.
557
572
 
@@ -572,7 +587,7 @@ View quick metadata about your dataframe and columns to understand their structu
572
587
  **In Metadata Modals**:
573
588
  - Press `q` or `Escape` to close
574
589
 
575
- ### 9. Frequency Distribution
590
+ ### 10. Frequency Distribution
576
591
 
577
592
  Press `F` to see value distributions of the current column. The modal shows:
578
593
  - Value, Count, Percentage, Histogram
@@ -594,7 +609,7 @@ This is useful for:
594
609
  - Identifying rare or common values
595
610
  - Finding the most/least frequent entries
596
611
 
597
- ### 10. Column & Dataframe Statistics
612
+ ### 11. Column & Dataframe Statistics
598
613
 
599
614
  Show summary statistics (count, null count, mean, median, std, min, max, etc.) using Polars' `describe()` method.
600
615
  - `s` for the current column
@@ -612,7 +627,7 @@ This is useful for:
612
627
  - Quick statistical summaries without external tools
613
628
  - Comparing statistics across columns
614
629
 
615
- ### 11. Editing
630
+ ### 12. Editing
616
631
 
617
632
  **Edit Cell** (`e` or **Double-click**):
618
633
  - Opens modal for editing current cell
@@ -660,7 +675,7 @@ This is useful for:
660
675
  - `h` - Temporarily hide current column (data preserved)
661
676
  - `H` - Restore all hidden columns
662
677
 
663
- ### 12. Column & Row Reordering
678
+ ### 13. Column & Row Reordering
664
679
 
665
680
  **Move Columns**: `Shift+←` and `Shift+→`
666
681
  - Swaps adjacent columns
@@ -670,12 +685,12 @@ This is useful for:
670
685
  - Swaps adjacent rows
671
686
  - Reorder is preserved when saving
672
687
 
673
- ### 13. Freeze Rows and Columns
688
+ ### 14. Freeze Rows and Columns
674
689
 
675
- Press `z` to open the dialog:
690
+ Press `f` to open the dialog:
676
691
  - Enter number of fixed rows and/or columns to keep top rows/columns visible while scrolling
677
692
 
678
- ### 14. Thousand Separator Toggle
693
+ ### 15. Thousand Separator Toggle
679
694
 
680
695
  Press `,` to toggle thousand separator formatting for numeric data:
681
696
  - Applies to **integer** and **float** columns
@@ -685,11 +700,11 @@ Press `,` to toggle thousand separator formatting for numeric data:
685
700
  - Display-only: does not modify underlying data in the dataframe
686
701
  - State persists during the session
687
702
 
688
- ### 15. Save File
703
+ ### 16. Save File
689
704
 
690
705
  Press `Ctrl+S` to save filtered, edited, or sorted data back to file. The output format is automatically determined by the file extension, making it easy to convert between different formats (e.g., CSV to TSV).
691
706
 
692
- ### 16. Undo/Redo/Reset
707
+ ### 17. Undo/Redo/Reset
693
708
 
694
709
  **Undo** (`u`):
695
710
  - Reverts last action with full state restoration
@@ -707,7 +722,7 @@ Press `Ctrl+S` to save filtered, edited, or sorted data back to file. The output
707
722
  - Clears all edits, deletions, selections, filters, and sorts
708
723
  - Useful for starting fresh without reloading the file
709
724
 
710
- ### 17. Column Type Conversion
725
+ ### 18. Column Type Conversion
711
726
 
712
727
  Press the type conversion keys to instantly cast the current column to a different data type:
713
728
 
@@ -724,14 +739,14 @@ Press the type conversion keys to instantly cast the current column to a differe
724
739
 
725
740
  **Note**: Type conversion attempts to preserve data where possible. Conversions may lose data (e.g., float to int rounding).
726
741
 
727
- ### 18. Cursor Type Cycling
742
+ ### 19. Cursor Type Cycling
728
743
 
729
744
  Press `K` to cycle through selection modes:
730
745
  1. **Cell mode**: Highlight individual cell (and its row/column headers)
731
746
  2. **Row mode**: Highlight entire row
732
747
  3. **Column mode**: Highlight entire column
733
748
 
734
- ### 19. SQL Interface
749
+ ### 20. SQL Interface
735
750
 
736
751
  The SQL interface provides two modes for querying your dataframe:
737
752
 
@@ -761,7 +776,7 @@ FROM self
761
776
  WHERE `product id` = 7
762
777
  ```
763
778
 
764
- ### 20. Clipboard Operations
779
+ ### 21. Clipboard Operations
765
780
 
766
781
  Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux.
767
782
 
@@ -772,7 +787,7 @@ Copies value to system clipboard with `pbcopy` on macOS and `xclip` on Linux.
772
787
  - Press `Ctrl+R` to copy row values (delimited by tab)
773
788
  - Hold `Shift` to select with mouse
774
789
 
775
- ### 21. Link Column Creation
790
+ ### 22. Link Column Creation
776
791
 
777
792
  Press `@` to create a new column containing dynamically generated URLs using template.
778
793
 
@@ -794,16 +809,17 @@ The link template supports multiple placeholder types for maximum flexibility:
794
809
  - Use full undo (`u`) if template produces unexpected URLs
795
810
  - For complex multi-column URLs, use column names (`$name`) for clarity over positions (`$1`)
796
811
 
797
- ### 22. Tab Management
812
+ ### 23. Tab Management
798
813
 
799
814
  Manage multiple files and dataframes simultaneously with tabs.
800
815
 
801
816
  **Tab Operations:**
802
817
  - **`Ctrl+O`** - Open file in a new tab
803
- - **`>`** - Move to next tab
804
- - **`<`** - Move to previous tab
805
- - **`b`** - Cycle through tabs
806
- - **`B`** - Toggle tab bar visibility
818
+ - **`b`** - Go to the next tab
819
+ - **`B`** - Go to the previous tab
820
+ - **`space`** - Toggle the tab bar visibility
821
+ - **`>`** - Move the current tab right
822
+ - **`<`** - Move the current tab left
807
823
  - **`Double-click`** - Rename the tab
808
824
  - **`Ctrl+D`** - Duplicate current tab (creates a copy with same data and state)
809
825
  - **`Ctrl+T`** - Save current tab to file
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "dataframe-textual"
7
- version = "2.38.0"
7
+ version = "2.40.1"
8
8
  description = "Interactive terminal viewer/editor for tabular data"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -14,6 +14,7 @@ from typing import Any
14
14
  import polars as pl
15
15
  import xlsxwriter
16
16
  from rich.text import Text
17
+ from textual.widgets import DataTable
17
18
 
18
19
  # Supported file formats
19
20
  SUPPORTED_FORMATS = {
@@ -96,6 +97,9 @@ class DtypeClass:
96
97
 
97
98
  Args:
98
99
  val: The value to format.
100
+ style: Optional style override for display. Defaults to None.
101
+ justify: Optional justification (e.g., left, right, center) override for display. Defaults to None.
102
+ thousand_separator: Whether to include thousand separators for numeric values. Defaults to False.
99
103
 
100
104
  Returns:
101
105
  The formatted value as a Text.
@@ -113,7 +117,7 @@ class DtypeClass:
113
117
  return Text(
114
118
  text_val,
115
119
  style="" if style == "" else (style or self.style),
116
- justify="" if justify == "" else (justify or self.justify),
120
+ justify=justify or self.justify,
117
121
  overflow="ellipsis",
118
122
  no_wrap=True,
119
123
  )
@@ -145,7 +149,7 @@ STYLES = {
145
149
  pl.Datetime: DtypeClass(gtype="temporal", style="magenta", justify="center", itype="text", convert=str),
146
150
  pl.Time: DtypeClass(gtype="temporal", style="magenta", justify="center", itype="text", convert=str),
147
151
  # unknown
148
- pl.Unknown: DtypeClass(gtype="unknown", style="", justify="", itype="text", convert=str),
152
+ pl.Unknown: DtypeClass(gtype="unknown", style="", justify=None, itype="text", convert=str),
149
153
  }
150
154
  # fmt: on
151
155
 
@@ -1039,3 +1043,41 @@ def write_file(sources: list[Source], filename: str) -> None:
1039
1043
  except Exception as e:
1040
1044
  print(f"Error writing to output file: {e}", file=sys.stderr)
1041
1045
  sys.exit(1)
1046
+
1047
+
1048
+ def df2table(
1049
+ df: pl.DataFrame,
1050
+ table: DataTable | None = None,
1051
+ hidden_columns: list[str] | None = None,
1052
+ thousand_separator: bool = False,
1053
+ ) -> DataTable:
1054
+ """Convert a Polars DataFrame to a DataTable for display.
1055
+
1056
+ Args:
1057
+ df: The Polars DataFrame to convert.
1058
+ table: An optional DataTable to populate. If None, a new DataTable is created.
1059
+ hidden_columns: An optional list of columns to hide in the DataTable.
1060
+ thousand_separator: Whether to use a thousand separator for numeric values.
1061
+
1062
+ Returns:
1063
+ A DataTable representing the DataFrame.
1064
+ """
1065
+
1066
+ if table is None:
1067
+ table = DataTable(zebra_stripes=True)
1068
+ else:
1069
+ table.clear(columns=True)
1070
+
1071
+ # Add columns with proper justification based on data types
1072
+ for col, dtype in zip(df.columns, df.dtypes):
1073
+ if col == RID or (hidden_columns and col in hidden_columns):
1074
+ continue
1075
+ dc = DtypeConfig(dtype)
1076
+ table.add_column(Text(col, justify=dc.justify), key=col)
1077
+
1078
+ # Add rows with proper formatting based on data types
1079
+ for idx, row in enumerate(df.iter_rows()):
1080
+ formatted_row = format_row(row, df.dtypes, thousand_separator=thousand_separator)
1081
+ table.add_row(*formatted_row, label=str(idx + 1))
1082
+
1083
+ return table