statstudio 0.1.0__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.
Files changed (110) hide show
  1. statstudio/__init__.py +9 -0
  2. statstudio/__main__.py +3 -0
  3. statstudio/app.py +83 -0
  4. statstudio/cli.py +116 -0
  5. statstudio/core/__init__.py +3 -0
  6. statstudio/core/archive.py +27 -0
  7. statstudio/core/commands.py +67 -0
  8. statstudio/core/formula_catalog.py +74 -0
  9. statstudio/core/formulas.py +605 -0
  10. statstudio/core/joins.py +123 -0
  11. statstudio/core/project.py +358 -0
  12. statstudio/core/runtime.py +321 -0
  13. statstudio/core/scripting.py +594 -0
  14. statstudio/core/table.py +796 -0
  15. statstudio/core/transform.py +450 -0
  16. statstudio/feature_help.py +595 -0
  17. statstudio/io/__init__.py +3 -0
  18. statstudio/io/docx.py +201 -0
  19. statstudio/io/export.py +99 -0
  20. statstudio/io/file_import.py +199 -0
  21. statstudio/io/odbc.py +334 -0
  22. statstudio/io/sample_data.py +164 -0
  23. statstudio/io/table_io.py +118 -0
  24. statstudio/plots/__init__.py +19 -0
  25. statstudio/plots/advanced.py +651 -0
  26. statstudio/plots/basic.py +957 -0
  27. statstudio/plots/bayesian_plots.py +94 -0
  28. statstudio/plots/common.py +334 -0
  29. statstudio/plots/diagnostics.py +214 -0
  30. statstudio/plots/doe_plots.py +235 -0
  31. statstudio/plots/plotly_builders.py +719 -0
  32. statstudio/plots/predictive_plots.py +72 -0
  33. statstudio/plots/registry.py +251 -0
  34. statstudio/plugins.py +111 -0
  35. statstudio/resources/help_topics.json +13195 -0
  36. statstudio/resources/logo.ico +0 -0
  37. statstudio/resources/logo.png +0 -0
  38. statstudio/resources/statstudio.svg +8 -0
  39. statstudio/stats/__init__.py +42 -0
  40. statstudio/stats/bayesian.py +1094 -0
  41. statstudio/stats/bayesian_optimization.py +590 -0
  42. statstudio/stats/common.py +140 -0
  43. statstudio/stats/correlation.py +135 -0
  44. statstudio/stats/custom_doe.py +1714 -0
  45. statstudio/stats/descriptive.py +200 -0
  46. statstudio/stats/desirability.py +132 -0
  47. statstudio/stats/distributions.py +331 -0
  48. statstudio/stats/doe.py +1070 -0
  49. statstudio/stats/hypothesis.py +1305 -0
  50. statstudio/stats/multivariate.py +307 -0
  51. statstudio/stats/optimal_doe.py +264 -0
  52. statstudio/stats/power.py +194 -0
  53. statstudio/stats/predictive.py +605 -0
  54. statstudio/stats/profiler.py +379 -0
  55. statstudio/stats/quality.py +1218 -0
  56. statstudio/stats/regression.py +1600 -0
  57. statstudio/stats/results.py +235 -0
  58. statstudio/stats/simulator.py +95 -0
  59. statstudio/stats/survival.py +637 -0
  60. statstudio/stats/timeseries.py +643 -0
  61. statstudio/stats/tolerance.py +154 -0
  62. statstudio/ui/__init__.py +0 -0
  63. statstudio/ui/analysis_hub.py +271 -0
  64. statstudio/ui/command_catalog.py +460 -0
  65. statstudio/ui/command_palette.py +55 -0
  66. statstudio/ui/console.py +239 -0
  67. statstudio/ui/dialogs/__init__.py +0 -0
  68. statstudio/ui/dialogs/advanced_dialogs.py +392 -0
  69. statstudio/ui/dialogs/base.py +537 -0
  70. statstudio/ui/dialogs/bayesian_dialogs.py +488 -0
  71. statstudio/ui/dialogs/bayesian_optimization_dialog.py +299 -0
  72. statstudio/ui/dialogs/custom_doe_dialog.py +467 -0
  73. statstudio/ui/dialogs/doe_dialogs.py +220 -0
  74. statstudio/ui/dialogs/extended_dialogs.py +665 -0
  75. statstudio/ui/dialogs/graph_builder.py +139 -0
  76. statstudio/ui/dialogs/help_dialog.py +207 -0
  77. statstudio/ui/dialogs/help_topics.py +280 -0
  78. statstudio/ui/dialogs/lazy.py +184 -0
  79. statstudio/ui/dialogs/odbc_dialog.py +311 -0
  80. statstudio/ui/dialogs/plot_dialog.py +1385 -0
  81. statstudio/ui/dialogs/report_composer.py +218 -0
  82. statstudio/ui/dialogs/script_dialogs.py +267 -0
  83. statstudio/ui/dialogs/stats_dialogs.py +1688 -0
  84. statstudio/ui/dialogs/table_dialogs.py +997 -0
  85. statstudio/ui/dialogs/window.py +58 -0
  86. statstudio/ui/docks/__init__.py +0 -0
  87. statstudio/ui/formula_editor.py +121 -0
  88. statstudio/ui/icons.py +257 -0
  89. statstudio/ui/jobs.py +179 -0
  90. statstudio/ui/main_window.py +3934 -0
  91. statstudio/ui/plot_interaction.py +178 -0
  92. statstudio/ui/profiler_widget.py +437 -0
  93. statstudio/ui/recent.py +82 -0
  94. statstudio/ui/reports/__init__.py +0 -0
  95. statstudio/ui/reports/report_view.py +1632 -0
  96. statstudio/ui/script_jobs.py +35 -0
  97. statstudio/ui/scripts_panel.py +271 -0
  98. statstudio/ui/table_document.py +233 -0
  99. statstudio/ui/table_model.py +285 -0
  100. statstudio/ui/table_view.py +285 -0
  101. statstudio/ui/theme.py +645 -0
  102. statstudio/ui/welcome.py +453 -0
  103. statstudio/ui/window_controls.py +53 -0
  104. statstudio/ui/workers.py +53 -0
  105. statstudio-0.1.0.dist-info/METADATA +261 -0
  106. statstudio-0.1.0.dist-info/RECORD +110 -0
  107. statstudio-0.1.0.dist-info/WHEEL +5 -0
  108. statstudio-0.1.0.dist-info/entry_points.txt +5 -0
  109. statstudio-0.1.0.dist-info/licenses/LICENSE +674 -0
  110. statstudio-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,450 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Mapping, Sequence
4
+
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ from statstudio.core.formulas import evaluate_formula, formula_to_series
9
+ from statstudio.core.table import ColumnSpec, DataTable
10
+
11
+
12
+ class TransformError(ValueError):
13
+ pass
14
+
15
+
16
+ def filter_table(table: DataTable, expression: str, name: str | None = None) -> DataTable:
17
+ source = table.analysis_df(include_excluded=True)
18
+ mask = evaluate_formula(source, expression)
19
+ if not isinstance(mask, pd.Series):
20
+ raise TransformError("Filter expression must produce a boolean column.")
21
+ mask = mask.reindex(source.index, fill_value=False).fillna(False).astype(bool)
22
+ frame = source.loc[mask].reset_index(drop=True)
23
+ result = DataTable(
24
+ frame,
25
+ name=name or f"{table.name} Filtered",
26
+ source=f"Filter: {expression}",
27
+ metadata=dict(table.metadata),
28
+ )
29
+ result.metadata["filter_source"] = table.name
30
+ result.metadata["filter_expression"] = expression
31
+ return result
32
+
33
+
34
+ def split_table(table: DataTable, column: str) -> list[DataTable]:
35
+ if column not in table.data.columns:
36
+ raise TransformError(f"Unknown column: {column}")
37
+ frame = table.analysis_df(include_excluded=True)
38
+ results: list[DataTable] = []
39
+ for value, group in frame.groupby(column, dropna=False, sort=True, observed=True):
40
+ label = "Missing" if pd.isna(value) else str(value)
41
+ result = DataTable(
42
+ group.reset_index(drop=True),
43
+ name=f"{table.name} {column}={label}",
44
+ source=f"Split {table.name} by {column}",
45
+ metadata=dict(table.metadata),
46
+ )
47
+ results.append(result)
48
+ return results
49
+
50
+
51
+ def stack_table(
52
+ table: DataTable,
53
+ id_columns: Sequence[str],
54
+ value_columns: Sequence[str],
55
+ variable_name: str = "Variable",
56
+ value_name: str = "Value",
57
+ name: str | None = None,
58
+ ) -> DataTable:
59
+ missing = [c for c in list(id_columns) + list(value_columns) if c not in table.data.columns]
60
+ if missing:
61
+ raise TransformError(f"Unknown columns: {', '.join(missing)}")
62
+ result = table.analysis_df(include_excluded=True).melt(
63
+ id_vars=list(id_columns),
64
+ value_vars=list(value_columns),
65
+ var_name=variable_name,
66
+ value_name=value_name,
67
+ )
68
+ return DataTable(result, name=name or f"{table.name} Stacked", source=f"Stack {table.name}")
69
+
70
+
71
+ def unstack_table(
72
+ table: DataTable,
73
+ index_columns: Sequence[str],
74
+ column_column: str,
75
+ value_column: str,
76
+ aggregate: str = "mean",
77
+ name: str | None = None,
78
+ ) -> DataTable:
79
+ missing = [c for c in list(index_columns) + [column_column, value_column] if c not in table.data.columns]
80
+ if missing:
81
+ raise TransformError(f"Unknown columns: {', '.join(missing)}")
82
+ frame = table.analysis_df(include_excluded=True)
83
+ pivot = frame.pivot_table(
84
+ index=list(index_columns),
85
+ columns=column_column,
86
+ values=value_column,
87
+ aggfunc=aggregate,
88
+ dropna=False,
89
+ )
90
+ pivot.columns = [str(c) for c in pivot.columns]
91
+ result = pivot.reset_index()
92
+ return DataTable(result, name=name or f"{table.name} Unstacked", source=f"Unstack {table.name}")
93
+
94
+
95
+ def transpose_table(table: DataTable, name: str | None = None) -> DataTable:
96
+ frame = table.analysis_df(include_excluded=True)
97
+ if frame.empty:
98
+ raise TransformError("Cannot transpose an empty table.")
99
+ label_column = "Column"
100
+ index = pd.Index([str(c) for c in frame.columns], name=label_column)
101
+ transposed = pd.DataFrame(frame.to_numpy().T, index=index)
102
+ transposed.columns = [f"Row {i + 1}" for i in range(transposed.shape[1])]
103
+ result = transposed.reset_index()
104
+ return DataTable(result, name=name or f"{table.name} Transposed", source=f"Transpose {table.name}")
105
+
106
+
107
+ def recode_column(
108
+ table: DataTable,
109
+ column: str,
110
+ mapping: Mapping[Any, Any],
111
+ default: Any = None,
112
+ new_name: str | None = None,
113
+ keep_unmapped: bool = True,
114
+ ) -> DataTable:
115
+ if column not in table.data.columns:
116
+ raise TransformError(f"Unknown column: {column}")
117
+ result = table.copy()
118
+ source = result.data[column]
119
+
120
+ def is_missing(value: Any) -> bool:
121
+ try:
122
+ outcome = pd.isna(value)
123
+ except (TypeError, ValueError):
124
+ return False
125
+ return bool(outcome) if np.isscalar(outcome) else False
126
+
127
+ sentinel = object()
128
+
129
+ def normalize(value: Any) -> Any:
130
+ return sentinel if is_missing(value) else value
131
+
132
+ normalized = source.map(normalize)
133
+ normalized_mapping = {normalize(key): value for key, value in mapping.items()}
134
+ values = normalized.map(normalized_mapping)
135
+ mapped = normalized.isin(list(normalized_mapping.keys()))
136
+ if keep_unmapped:
137
+ values = values.where(mapped, source)
138
+ else:
139
+ missing_mask = source.map(is_missing).astype(bool)
140
+ default_values = pd.Series(default, index=source.index, dtype=object)
141
+ fallback = default_values.where(~missing_mask, source)
142
+ values = values.where(mapped, fallback)
143
+ target = new_name or column
144
+ if target == column:
145
+ result.replace_column(column, values)
146
+ else:
147
+ result.add_column(target, values)
148
+ return result
149
+
150
+
151
+ def replace_missing(
152
+ table: DataTable,
153
+ column: str,
154
+ value: Any = 0,
155
+ new_name: str | None = None,
156
+ ) -> DataTable:
157
+ if column not in table.data.columns:
158
+ raise TransformError(f"Unknown column: {column}")
159
+ result = table.copy()
160
+ values = result.data[column].fillna(value)
161
+ if new_name:
162
+ result.add_column(new_name, values)
163
+ else:
164
+ result.replace_column(column, values)
165
+ return result
166
+
167
+
168
+ def add_formula_column(
169
+ table: DataTable,
170
+ name: str,
171
+ formula: str,
172
+ description: str = "",
173
+ ) -> None:
174
+ if not name.strip():
175
+ raise TransformError("Column name cannot be empty.")
176
+ from statstudio.core.table import _infer_data_type, _infer_modeling_type
177
+
178
+ series = formula_to_series(table.data, formula, name=name)
179
+ spec = ColumnSpec(
180
+ name=name,
181
+ data_type=_infer_data_type(series),
182
+ modeling_type=_infer_modeling_type(series),
183
+ formula=formula,
184
+ notes=description,
185
+ )
186
+ table.add_column(name, series, spec=spec, formula=formula)
187
+
188
+
189
+ def subset_columns(table: DataTable, columns: Sequence[str], name: str | None = None) -> DataTable:
190
+ missing = [c for c in columns if c not in table.data.columns]
191
+ if missing:
192
+ raise TransformError(f"Unknown columns: {', '.join(missing)}")
193
+ frame = table.analysis_df(include_excluded=True).loc[:, list(columns)].reset_index(drop=True)
194
+ return DataTable(
195
+ frame,
196
+ name=name or f"{table.name} Subset",
197
+ source=f"Columns from {table.name}",
198
+ specs={c: ColumnSpec.from_dict(table.specs[c].to_dict()) for c in columns},
199
+ metadata=dict(table.metadata),
200
+ )
201
+
202
+
203
+ def add_empty_column(
204
+ table: DataTable,
205
+ name: str,
206
+ data_type: str = "numeric",
207
+ default: Any = None,
208
+ ) -> None:
209
+ if name in table.data.columns:
210
+ raise TransformError(f"Column {name!r} already exists.")
211
+ if data_type == "numeric":
212
+ value = default if default not in {None, ""} else np.nan
213
+ try:
214
+ value = float(value)
215
+ except (TypeError, ValueError):
216
+ raise TransformError("Default value must be numeric.") from None
217
+ series = pd.Series(value, index=table.data.index, dtype=float)
218
+ modeling = "continuous"
219
+ elif data_type == "date":
220
+ series = pd.Series(pd.to_datetime(default) if default else pd.NaT, index=table.data.index, dtype="datetime64[ns]")
221
+ modeling = "continuous"
222
+ else:
223
+ series = pd.Series("" if default is None else str(default), index=table.data.index, dtype=object)
224
+ modeling = "nominal"
225
+ table.add_column(
226
+ name,
227
+ series,
228
+ ColumnSpec(name=name, data_type=data_type, modeling_type=modeling),
229
+ )
230
+
231
+
232
+ def standardize_columns(table: DataTable, columns: Sequence[str], suffix: str = "_z") -> None:
233
+ for column in columns:
234
+ if column not in table.data.columns:
235
+ raise TransformError(f"Unknown column: {column}")
236
+ series = pd.to_numeric(table.data[column], errors="coerce")
237
+ std = series.std(ddof=1)
238
+ if std and not pd.isna(std):
239
+ table.add_column(f"{column}{suffix}", (series - series.mean()) / std)
240
+
241
+
242
+ def _new_row_index(table: DataTable, count: int) -> pd.Index:
243
+ existing = list(table.data.index)
244
+ numeric: list[int] = []
245
+ for value in existing:
246
+ if isinstance(value, (int, np.integer)):
247
+ numeric.append(int(value))
248
+ elif isinstance(value, (float, np.floating)) and float(value).is_integer():
249
+ numeric.append(int(value))
250
+ start = (max(numeric) + 1) if numeric else len(existing)
251
+ used = set(existing)
252
+ while any(value in used for value in range(start, start + count)):
253
+ start += 1
254
+ return pd.RangeIndex(start, start + count)
255
+
256
+
257
+ def duplicate_rows(table: DataTable, row_ids: Sequence[Any]) -> int:
258
+ row_ids = [row_id for row_id in row_ids if row_id in table.data.index]
259
+ if not row_ids:
260
+ return 0
261
+ copies = table.data.loc[row_ids].copy()
262
+ new_index = _new_row_index(table, len(copies))
263
+ copies.index = new_index
264
+ table._df = pd.concat([table.data, copies])
265
+ for source_id, target_id in zip(row_ids, new_index):
266
+ if source_id in table.excluded_rows:
267
+ table.excluded_rows.add(target_id)
268
+ if source_id in table.hidden_rows:
269
+ table.hidden_rows.add(target_id)
270
+ if source_id in table.row_labels:
271
+ table.row_labels[target_id] = table.row_labels[source_id]
272
+ if source_id in table.row_colors:
273
+ table.row_colors[target_id] = table.row_colors[source_id]
274
+ if source_id in table.row_markers:
275
+ table.row_markers[target_id] = table.row_markers[source_id]
276
+ table.recompute_formulas()
277
+ table.modified = True
278
+ return len(copies)
279
+
280
+
281
+ def delete_rows(table: DataTable, row_ids: Sequence[Any]) -> int:
282
+ ids = list(dict.fromkeys(row_id for row_id in row_ids if row_id in table.data.index))
283
+ if not ids:
284
+ return 0
285
+ table._df = table.data.drop(index=ids)
286
+ for row_id in ids:
287
+ table.excluded_rows.discard(row_id)
288
+ table.hidden_rows.discard(row_id)
289
+ table.row_labels.pop(row_id, None)
290
+ table.row_colors.pop(row_id, None)
291
+ table.row_markers.pop(row_id, None)
292
+ table.recompute_formulas()
293
+ table.modified = True
294
+ return len(ids)
295
+
296
+
297
+ def move_column(table: DataTable, column: str, offset: int) -> bool:
298
+ columns = list(table.data.columns)
299
+ if column not in columns:
300
+ raise TransformError(f"Unknown column: {column}")
301
+ index = columns.index(column)
302
+ target = max(0, min(len(columns) - 1, index + offset))
303
+ if target == index:
304
+ return False
305
+ columns.pop(index)
306
+ columns.insert(target, column)
307
+ table._df = table.data.loc[:, columns]
308
+ table.modified = True
309
+ return True
310
+
311
+
312
+ def unhide_all_columns(table: DataTable) -> None:
313
+ table.hidden_columns.clear()
314
+ table.modified = True
315
+
316
+
317
+ def find_replace(
318
+ table: DataTable,
319
+ columns: Sequence[str],
320
+ find: str,
321
+ replace: str,
322
+ *,
323
+ regex: bool = False,
324
+ match_case: bool = True,
325
+ whole_cell: bool = False,
326
+ ) -> int:
327
+ import re
328
+
329
+ missing = [c for c in columns if c not in table.data.columns]
330
+ if missing:
331
+ raise TransformError(f"Unknown columns: {', '.join(missing)}")
332
+ if find == "":
333
+ raise TransformError("Search text cannot be empty.")
334
+ formula_columns = {c for c in columns if table.specs.get(c) and table.specs[c].formula}
335
+ columns = [c for c in columns if c not in formula_columns]
336
+ pattern = find if regex else re.escape(find)
337
+ if whole_cell:
338
+ pattern = f"^(?:{pattern})\\Z"
339
+ flags = 0 if match_case else re.IGNORECASE
340
+ compiled = re.compile(pattern, flags)
341
+ repl = replace if regex else (lambda m: replace)
342
+ replacements = 0
343
+ for column in columns:
344
+ original = table.data[column]
345
+ was_numeric = pd.api.types.is_numeric_dtype(original) and not pd.api.types.is_bool_dtype(original)
346
+
347
+ def render(value):
348
+ if pd.isna(value):
349
+ return None
350
+ if isinstance(value, (float, np.floating)) and np.isfinite(value) and float(value).is_integer():
351
+ return str(int(value))
352
+ return str(value)
353
+
354
+ text = original.map(render)
355
+ updated = text.map(lambda value: None if value is None else compiled.sub(repl, value))
356
+ mask = text.notna() & updated.notna() & (updated != text)
357
+ count = int(mask.sum())
358
+ if not count:
359
+ continue
360
+ replacements += count
361
+ if was_numeric:
362
+ numeric = pd.to_numeric(updated, errors="coerce")
363
+ if numeric[mask].isna().any():
364
+ raise TransformError(
365
+ f"Replacement would make numeric column '{column}' non-numeric."
366
+ )
367
+ if original.dtype.kind in "iu":
368
+ changed = numeric[mask].to_numpy(dtype=float)
369
+ if not np.allclose(changed, np.round(changed)):
370
+ raise TransformError(
371
+ f"Replacement would truncate integer column '{column}'."
372
+ )
373
+ numeric = numeric.astype(original.dtype)
374
+ table._df[column] = numeric.where(text.notna(), original)
375
+ continue
376
+ replacement_values = original.astype(object).copy()
377
+ replacement_values[mask] = updated[mask]
378
+ table._df[column] = replacement_values.where(original.notna(), original)
379
+ if replacements:
380
+ table.recompute_formulas()
381
+ table.modified = True
382
+ return replacements
383
+
384
+
385
+ def boxcox_column(table: DataTable, column: str, new_name: str | None = None, shift: float | None = None) -> tuple[DataTable, float]:
386
+ from scipy import stats
387
+
388
+ if column not in table.data.columns:
389
+ raise TransformError(f"Unknown column: {column}")
390
+ values = pd.to_numeric(table.data[column], errors="coerce")
391
+ clean = values.dropna()
392
+ if len(clean) < 2:
393
+ raise TransformError("Box-Cox requires at least two non-missing values.")
394
+ minimum = float(clean.min())
395
+ offset = shift if shift is not None else (abs(minimum) + 1.0 if minimum <= 0 else 0.0)
396
+ shifted = clean + offset
397
+ if (shifted <= 0).any():
398
+ raise TransformError("Box-Cox requires strictly positive values; supply or increase the shift.")
399
+ transformed, lam = stats.boxcox(shifted.to_numpy(dtype=float))
400
+ result = table.copy()
401
+ target = new_name or f"{column}_BoxCox"
402
+ series = pd.Series(np.nan, index=result.data.index, dtype=float)
403
+ series.loc[clean.index] = transformed
404
+ result.add_column(target, series, ColumnSpec(name=target, data_type="numeric", modeling_type="continuous", notes=f"Box-Cox lambda={lam:.6g}, shift={offset:.6g}"))
405
+ return result, float(lam)
406
+
407
+
408
+ def rank_column(table: DataTable, column: str, new_name: str | None = None, method: str = "average") -> DataTable:
409
+ if column not in table.data.columns:
410
+ raise TransformError(f"Unknown column: {column}")
411
+ result = table.copy()
412
+ target = new_name or f"{column}_Rank"
413
+ result.add_column(target, pd.to_numeric(result.data[column], errors="coerce").rank(method=method), ColumnSpec(name=target, data_type="numeric", modeling_type="continuous"))
414
+ return result
415
+
416
+
417
+ def bin_column(
418
+ table: DataTable,
419
+ column: str,
420
+ bins: int | Sequence[float] = 5,
421
+ labels: Sequence[str] | None = None,
422
+ new_name: str | None = None,
423
+ ) -> DataTable:
424
+ if column not in table.data.columns:
425
+ raise TransformError(f"Unknown column: {column}")
426
+ result = table.copy()
427
+ target = new_name or f"{column}_Bin"
428
+ binned = pd.cut(pd.to_numeric(result.data[column], errors="coerce"), bins=bins, labels=labels, include_lowest=True)
429
+ result.add_column(target, binned.astype(object), ColumnSpec(name=target, data_type="categorical", modeling_type="nominal"))
430
+ return result
431
+
432
+
433
+ def text_to_columns(
434
+ table: DataTable,
435
+ column: str,
436
+ separator: str = ",",
437
+ new_names: Sequence[str] | None = None,
438
+ ) -> DataTable:
439
+ if column not in table.data.columns:
440
+ raise TransformError(f"Unknown column: {column}")
441
+ result = table.copy()
442
+ values = result.data[column]
443
+ valid = values.notna()
444
+ split = values.where(valid, "").astype(str).str.split(separator, expand=True, regex=False)
445
+ split = split.where(valid, None)
446
+ width = split.shape[1]
447
+ names = list(new_names or [f"{column}_{index + 1}" for index in range(width)])
448
+ for index, name in enumerate(names[:width]):
449
+ result.add_column(name, split.iloc[:, index], ColumnSpec(name=name, data_type="text", modeling_type="nominal"))
450
+ return result