dataframe-toolkit 0.12.0__tar.gz → 0.13.0__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 (54) hide show
  1. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/PKG-INFO +17 -1
  2. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/README.md +16 -0
  3. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/pyproject.toml +1 -1
  4. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/pyproject.toml.orig +1 -1
  5. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/eval_cmd.py +6 -0
  6. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/print_cmd.py +8 -6
  7. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/io.py +24 -6
  8. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/skills/dftk/SKILL.md +3 -2
  9. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/__init__.py +0 -0
  10. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/cli.py +0 -0
  11. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/__init__.py +0 -0
  12. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/annotate_cmd.py +0 -0
  13. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/base.py +0 -0
  14. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/binx_cmd.py +0 -0
  15. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/chi_cmd.py +0 -0
  16. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/clean_cmd.py +0 -0
  17. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/cleannames_cmd.py +0 -0
  18. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/concat_cmd.py +0 -0
  19. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/corr_cmd.py +0 -0
  20. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/dataset_cmd.py +0 -0
  21. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/describe_cmd.py +0 -0
  22. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/explode_cmd.py +0 -0
  23. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/fit_cmd.py +0 -0
  24. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/func_cmd.py +0 -0
  25. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/help.py +0 -0
  26. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/hist_cmd.py +0 -0
  27. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/implode_cmd.py +0 -0
  28. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/info_cmd.py +0 -0
  29. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/interp_cmd.py +0 -0
  30. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/line_cmd.py +0 -0
  31. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/melt_cmd.py +0 -0
  32. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/merge_cmd.py +0 -0
  33. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/pivot_cmd.py +0 -0
  34. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/query_cmd.py +0 -0
  35. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/randvar_cmd.py +0 -0
  36. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/sample_cmd.py +0 -0
  37. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/scale_cmd.py +0 -0
  38. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/scat_cmd.py +0 -0
  39. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/segid_cmd.py +0 -0
  40. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/skill_cmd.py +0 -0
  41. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/split_cmd.py +0 -0
  42. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/stat_cmd.py +0 -0
  43. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/test_cmd.py +0 -0
  44. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/transpose_cmd.py +0 -0
  45. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/commands/wstat_cmd.py +0 -0
  46. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/__init__.py +0 -0
  47. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/copula.py +0 -0
  48. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/evalfuncs.py +0 -0
  49. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/plot.py +0 -0
  50. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/seed.py +0 -0
  51. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/seq.py +0 -0
  52. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/common/stats.py +0 -0
  53. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/io.py +0 -0
  54. {dataframe_toolkit-0.12.0 → dataframe_toolkit-0.13.0}/src/dftk/skills/dftk/references/snakemake.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dataframe-toolkit
3
- Version: 0.12.0
3
+ Version: 0.13.0
4
4
  Summary: A command-line toolkit for DataFrame analysis and manipulation
5
5
  Keywords: dataframe,statistics,data analysis,CLI,TSV,pandas
6
6
  Author: Gunnar Pálsson
@@ -416,6 +416,20 @@ dftk print <(grep -v '^#' data.tsv) # the same, as a filename
416
416
  With `--backend duckdb`, a whole-line `#` comment below the header is an
417
417
  error, and `#` lines above the header are skipped.
418
418
 
419
+ ### Files without a header
420
+
421
+ `--noheader` reads the first line as data and names the columns `V1`,
422
+ `V2`, …. It only describes the input: the output gets a header (`V1 V2 …`)
423
+ unless you add `--removeheader`. Name the columns with `--move`:
424
+
425
+ ```bash
426
+ dftk print data.txt --noheader --move V1:chr V2:begin V3:end -o named.tsv
427
+ dftk eval data.txt --noheader -f "len = V3 - V2" --removeheader # no header out
428
+ ```
429
+
430
+ Parquet always has column names, so `--removeheader` with `-o` and
431
+ `--noheader` on parquet input do nothing (dftk warns).
432
+
419
433
  Standard output options (available on all tabular commands):
420
434
 
421
435
  - `-o` / `--output` — controls where output goes; takes an *optional* value:
@@ -427,6 +441,8 @@ Standard output options (available on all tabular commands):
427
441
  - `--drop col1 col2 …` — remove these columns
428
442
  - `--round N` — round numeric output
429
443
  - `--postquery EXPR` — filter output rows after processing
444
+ - `--move OLD:NEW …` — rename columns
445
+ - `--removeheader` — leave out the header row in TSV output
430
446
  - `--meta KEY=VALUE` — embed provenance metadata in parquet output (repeatable)
431
447
 
432
448
  ### Provenance annotations
@@ -386,6 +386,20 @@ dftk print <(grep -v '^#' data.tsv) # the same, as a filename
386
386
  With `--backend duckdb`, a whole-line `#` comment below the header is an
387
387
  error, and `#` lines above the header are skipped.
388
388
 
389
+ ### Files without a header
390
+
391
+ `--noheader` reads the first line as data and names the columns `V1`,
392
+ `V2`, …. It only describes the input: the output gets a header (`V1 V2 …`)
393
+ unless you add `--removeheader`. Name the columns with `--move`:
394
+
395
+ ```bash
396
+ dftk print data.txt --noheader --move V1:chr V2:begin V3:end -o named.tsv
397
+ dftk eval data.txt --noheader -f "len = V3 - V2" --removeheader # no header out
398
+ ```
399
+
400
+ Parquet always has column names, so `--removeheader` with `-o` and
401
+ `--noheader` on parquet input do nothing (dftk warns).
402
+
389
403
  Standard output options (available on all tabular commands):
390
404
 
391
405
  - `-o` / `--output` — controls where output goes; takes an *optional* value:
@@ -397,6 +411,8 @@ Standard output options (available on all tabular commands):
397
411
  - `--drop col1 col2 …` — remove these columns
398
412
  - `--round N` — round numeric output
399
413
  - `--postquery EXPR` — filter output rows after processing
414
+ - `--move OLD:NEW …` — rename columns
415
+ - `--removeheader` — leave out the header row in TSV output
400
416
  - `--meta KEY=VALUE` — embed provenance metadata in parquet output (repeatable)
401
417
 
402
418
  ### Provenance annotations
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataframe-toolkit"
3
- version = "0.12.0"
3
+ version = "0.13.0"
4
4
  description = "A command-line toolkit for DataFrame analysis and manipulation"
5
5
  readme = "README.md"
6
6
  keywords = [
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataframe-toolkit"
3
- version = "0.12.0"
3
+ version = "0.13.0"
4
4
  description = "A command-line toolkit for DataFrame analysis and manipulation"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -44,6 +44,12 @@ methods are under .str (name.str.lower(), not name.lower() or tolower()):
44
44
 
45
45
  x = x.abs() x = x.round(1) x = x.clip(lower=0) y = name.str.upper()
46
46
 
47
+ A regular expression test gives True/False; fullmatch checks the whole value
48
+ (match only its start). Here: exactly 7 ASCII letters, empty cells False:
49
+
50
+ dftk dataset diamonds -o \\
51
+ | dftk eval -f "is7 = cut.str.fullmatch('[A-Za-z]{7}')"
52
+
47
53
 
48
54
  FILLING MISSING VALUES (-f)
49
55
  ---------------------------
@@ -8,10 +8,13 @@ dftk pipeline:
8
8
  dftk stat -g grp -s val -o \\
9
9
  | dftk pivot -i grp -v val_mean -o \\
10
10
  | dftk print
11
+
12
+ With --noheader and --move it names the columns of a headerless file:
13
+
14
+ dftk print data.txt --noheader --move V1:chr V2:begin V3:end
11
15
  """
12
16
 
13
17
  import argparse
14
- import sys
15
18
 
16
19
  from dftk.commands.base import BaseCommand
17
20
  from dftk.common.io import io
@@ -24,10 +27,9 @@ class PrintCommand(BaseCommand):
24
27
  help = "Convert any input (TSV or parquet pipe) to TSV on stdout"
25
28
 
26
29
  def add_arguments(self, parser: argparse.ArgumentParser) -> None:
27
- # Only the read-side arguments — no -o/--output, since the whole
28
- # point of this command is to force TSV to stdout.
29
- io.parser_read(parser)
30
+ # The standard output options (--move, --select, --removeheader, …)
31
+ # work too; with -o FILE print writes there instead of stdout
32
+ self.add_io_arguments(parser)
30
33
 
31
34
  def execute(self, args: argparse.Namespace) -> None:
32
- df = io.read(args)
33
- df.to_csv(sys.stdout, sep="\t", index=False)
35
+ io.printdf(io.read(args), args)
@@ -91,6 +91,13 @@ def _is_temp_pipe_path(path: str) -> bool:
91
91
  _MAX_PATH_LINE = 4096
92
92
 
93
93
 
94
+ def _warn_noheader_parquet(args: argparse.Namespace) -> None:
95
+ if getattr(args, "noheader", False):
96
+ logging.warning(
97
+ "--noheader has no effect on parquet input; parquet always has column names"
98
+ )
99
+
100
+
94
101
  def _read_pipe_parquet(path: str) -> pd.DataFrame:
95
102
  """Read the parquet file *path* named on stdin; delete it if it's dftk's temp."""
96
103
  df = pd.read_parquet(path)
@@ -305,7 +312,11 @@ class io:
305
312
  )
306
313
  g.add_argument(
307
314
  "--noheader",
308
- help="File has no header row; columns are named V1, V2, …",
315
+ help=(
316
+ "Input has no header row; columns are named V1, V2, … "
317
+ "(rename with --move V1:NAME). Output still gets a header "
318
+ "unless --removeheader."
319
+ ),
309
320
  action="store_true",
310
321
  )
311
322
  g.add_argument(
@@ -418,6 +429,7 @@ class io:
418
429
  if _is_pipe_path(path):
419
430
  rest = stream.read()
420
431
  if not rest.strip():
432
+ _warn_noheader_parquet(args)
421
433
  return _read_pipe_parquet(path)
422
434
  stream = _io.BytesIO(rest)
423
435
  if backend == "duckdb" and duckdb is not None:
@@ -441,6 +453,7 @@ class io:
441
453
  raise ValueError(
442
454
  f"'...' expects a .parquet path on stdin, got {pipe_path!r}"
443
455
  )
456
+ _warn_noheader_parquet(args)
444
457
  df = _read_pipe_parquet(pipe_path)
445
458
 
446
459
  elif filename is not None and filename != "-":
@@ -453,6 +466,7 @@ class io:
453
466
  "stdin."
454
467
  )
455
468
  if filename.endswith(".parquet"):
469
+ _warn_noheader_parquet(args)
456
470
  df = pd.read_parquet(filename)
457
471
  df.attrs["_parquet_meta"] = _read_parquet_meta(filename)
458
472
  elif os.path.exists(filename) and not os.path.isfile(filename):
@@ -573,7 +587,8 @@ class io:
573
587
  )
574
588
  g.add_argument(
575
589
  "--removeheader",
576
- help="Suppress the header row in TSV output.",
590
+ help="Leave out the header row in TSV output (parquet always "
591
+ "keeps column names).",
577
592
  action="store_true",
578
593
  )
579
594
  g.add_argument(
@@ -819,10 +834,13 @@ class io:
819
834
  except ValueError:
820
835
  logging.warning(f"--meta: expected KEY=VALUE, got {item!r}")
821
836
 
822
- # Header: suppressed if the input had no header, or --removeheader set
823
- header = not getattr(args, "noheader", False)
824
- if header and getattr(args, "removeheader", False):
825
- header = False
837
+ # Header: written unless --removeheader (--noheader is about the input)
838
+ header = not getattr(args, "removeheader", False)
839
+ if not header and (output == "" or str(output).endswith(".parquet")):
840
+ logging.warning(
841
+ "--removeheader has no effect on parquet output (-o); parquet "
842
+ "always keeps column names"
843
+ )
826
844
 
827
845
  if output == "":
828
846
  # Pipe mode — write temp parquet, print path
@@ -75,8 +75,9 @@ left by an interrupted pipe are removed with `dftk clean`.
75
75
  ## Options shared by every data command
76
76
 
77
77
  Input: `--prequery EXPR` (filter rows right after reading), `--noheader`
78
- (columns become `V1, V2, …`), `--delimiter`, `--readasobject COL…` (keep
79
- values like IDs as strings).
78
+ (columns become `V1, V2, …`; the output still gets a header unless
79
+ `--removeheader`, and `--move V1:chr …` names them), `--delimiter`,
80
+ `--readasobject COL…` (keep values like IDs as strings).
80
81
 
81
82
  Output, applied after the command's own work: `--select COL… [+]` (choose
82
83
  and order columns; globs allowed; a trailing `+` keeps the remaining