You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tablecloth/api.clj
+28-3Lines changed: 28 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1505,6 +1505,31 @@ column-names function returns names according to columns-selector
1505
1505
1506
1506
1507
1507
(defnmap-column->columns
1508
+
"
1509
+
The map-column->columns function transforms a dataset by expanding a column containing map values into
1510
+
multiple new columns. Specifically, it takes a source dataset ds and a source column src-col within that dataset (which contains map values), and performs the following operations:
1511
+
1512
+
- Extracts the map data from src-col.
1513
+
- Creates a new dataset from this map data, where each key in the maps becomes a column.
1514
+
- Generates new column names by combining the name of src-col with each of the original map keys, using a dash (-) as a separator. The type (keyword, symbol, or string) of the new column names matches the type of src-col.
1515
+
- Appends these new columns to the original dataset ds.
1516
+
- Removes the original src-col from ds.
1517
+
1518
+
The result is a new dataset that includes all original columns (except src-col) and the newly expanded columns derived from the maps in src-col.
1519
+
Parameters
1520
+
1521
+
1522
+
'ds': The input dataset, expected to be a Tablecloth dataset or any dataset compatible with the functions used.
1523
+
'src-col': The name (keyword, symbol, or string) of the source column in ds that contains map values.
1524
+
1525
+
Return Value
1526
+
1527
+
A new dataset with the following characteristics:
1528
+
1529
+
Contains all columns from the original dataset ds, except the src-col.
1530
+
Includes new columns derived from the keys of the maps in src-col, with names formed by combining src-col and the map keys.
1531
+
The new columns are appropriately named and typed, maintaining the type consistency with src-col.
0 commit comments