Issue: Add column_names to IterableDataset
State: closed
Author: patrickloeber

This PR closes #5383 

* Add column_names property to IterableDataset
* Add multiple tests for this new property

Comments:
_The documentation is not available anymore as the PR was closed or merged._

<details>
<summary>Show benchmarks</summary>

PyArrow==8.0.0

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.006362 / 0.011353 (-0.004991) | 0.004546 / 0.011008 (-0.006462) | 0.097003 / 0.038508 (0.058495) | 0.028007 / 0.023109 (0.004898) | 0.315097 / 0.275898 (0.039199) | 0.365128 / 0.323480 (0.041649) | 0.004819 / 0.007986 (-0.003167) | 0.003335 / 0.004328 (-0.000994) | 0.076665 / 0.004250 (0.072415) | 0.038285 / 0.037052 (0.001233) | 0.322100 / 0.258489 (0.063611) | 0.407466 / 0.293841 (0.113625) | 0.031580 / 0.128546 (-0.096966) | 0.011645 / 0.075646 (-0.064001) | 0.321789 / 0.419271 (-0.097483) | 0.051015 / 0.043533 (0.007483) | 0.331762 / 0.255139 (0.076623) | 0.369727 / 0.283200 (0.086527) | 0.090144 / 0.141683 (-0.051539) | 1.485480 / 1.452155 (0.033326) | 1.562032 / 1.492716 (0.069316) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.201192 / 0.018006 (0.183186) | 0.409760 / 0.000490 (0.409270) | 0.002220 / 0.000200 (0.002020) | 0.000070 / 0.000054 (0.000016) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.022361 / 0.037411 (-0.015050) | 0.096375 / 0.014526 (0.081849) | 0.101369 / 0.176557 (-0.075188) | 0.161568 / 0.737135 (-0.575568) | 0.105094 / 0.296338 (-0.191245) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.426251 / 0.215209 (0.211042) | 4.261374 / 2.077655 (2.183720) | 2.015688 / 1.504120 (0.511569) | 1.833708 / 1.541195 (0.292513) | 1.908994 / 1.468490 (0.440504) | 0.703108 / 4.584777 (-3.881669) | 3.420767 / 3.745712 (-0.324945) | 1.844776 / 5.269862 (-3.425086) | 1.158470 / 4.565676 (-3.407207) | 0.083324 / 0.424275 (-0.340951) | 0.013054 / 0.007607 (0.005447) | 0.521473 / 0.226044 (0.295429) | 5.245505 / 2.268929 (2.976576) | 2.349110 / 55.444624 (-53.095515) | 2.011119 / 6.876477 (-4.865358) | 2.217807 / 2.142072 (0.075734) | 0.808584 / 4.805227 (-3.996643) | 0.151337 / 6.500664 (-6.349327) | 0.065815 / 0.075469 (-0.009654) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.221839 / 1.841788 (-0.619949) | 13.634161 / 8.074308 (5.559853) | 13.915360 / 10.191392 (3.723968) | 0.126448 / 0.680424 (-0.553976) | 0.016614 / 0.534201 (-0.517587) | 0.379150 / 0.579283 (-0.200133) | 0.382134 / 0.434364 (-0.052230) | 0.442845 / 0.540337 (-0.097493) | 0.519578 / 1.386936 (-0.867358) |

</details>
PyArrow==latest

<details>
<summary>Show updated benchmarks!</summary>

### Benchmark: benchmark_array_xd.json

| metric | read_batch_formatted_as_numpy after write_array2d | read_batch_formatted_as_numpy after write_flattened_sequence | read_batch_formatted_as_numpy after write_nested_sequence | read_batch_unformated after write_array2d | read_batch_unformated after write_flattened_sequence | read_batch_unformated after write_nested_sequence | read_col_formatted_as_numpy after write_array2d | read_col_formatted_as_numpy after write_flattened_sequence | read_col_formatted_as_numpy after write_nested_sequence | read_col_unformated after write_array2d | read_col_unformated after write_flattened_sequence | read_col_unformated after write_nested_sequence | read_formatted_as_numpy after write_array2d | read_formatted_as_numpy after write_flattened_sequence | read_formatted_as_numpy after write_nested_sequence | read_unformated after write_array2d | read_unformated after write_flattened_sequence | read_unformated after write_nested_sequence | write_array2d | write_flattened_sequence | write_nested_sequence |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.006238 / 0.011353 (-0.005115) | 0.004591 / 0.011008 (-0.006418) | 0.076652 / 0.038508 (0.038144) | 0.026882 / 0.023109 (0.003773) | 0.341948 / 0.275898 (0.066050) | 0.375244 / 0.323480 (0.051764) | 0.004770 / 0.007986 (-0.003215) | 0.004703 / 0.004328 (0.000374) | 0.075797 / 0.004250 (0.071547) | 0.035001 / 0.037052 (-0.002051) | 0.341670 / 0.258489 (0.083181) | 0.383028 / 0.293841 (0.089187) | 0.031756 / 0.128546 (-0.096791) | 0.011714 / 0.075646 (-0.063933) | 0.085552 / 0.419271 (-0.333720) | 0.047697 / 0.043533 (0.004164) | 0.340805 / 0.255139 (0.085666) | 0.365478 / 0.283200 (0.082278) | 0.093146 / 0.141683 (-0.048537) | 1.465100 / 1.452155 (0.012945) | 1.552708 / 1.492716 (0.059992) |

### Benchmark: benchmark_getitem\_100B.json

| metric | get_batch_of\_1024\_random_rows | get_batch_of\_1024\_rows | get_first_row | get_last_row |
|--------|---|---|---|---|
| new / old (diff) | 0.209117 / 0.018006 (0.191111) | 0.402622 / 0.000490 (0.402132) | 0.003940 / 0.000200 (0.003740) | 0.000078 / 0.000054 (0.000023) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.026027 / 0.037411 (-0.011385) | 0.098346 / 0.014526 (0.083820) | 0.107349 / 0.176557 (-0.069207) | 0.157846 / 0.737135 (-0.579289) | 0.109566 / 0.296338 (-0.186772) |

### Benchmark: benchmark_iterating.json

| metric | read 5000 | read 50000 | read_batch 50000 10 | read_batch 50000 100 | read_batch 50000 1000 | read_formatted numpy 5000 | read_formatted pandas 5000 | read_formatted tensorflow 5000 | read_formatted torch 5000 | read_formatted_batch numpy 5000 10 | read_formatted_batch numpy 5000 1000 | shuffled read 5000 | shuffled read 50000 | shuffled read_batch 50000 10 | shuffled read_batch 50000 100 | shuffled read_batch 50000 1000 | shuffled read_formatted numpy 5000 | shuffled read_formatted_batch numpy 5000 10 | shuffled read_formatted_batch numpy 5000 1000 |
|--------|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 0.445088 / 0.215209 (0.229879) | 4.450727 / 2.077655 (2.373072) | 2.237798 / 1.504120 (0.733678) | 2.026060 / 1.541195 (0.484866) | 2.020464 / 1.468490 (0.551974) | 0.700155 / 4.584777 (-3.884622) | 3.435497 / 3.745712 (-0.310215) | 2.851970 / 5.269862 (-2.417891) | 1.512689 / 4.565676 (-3.052988) | 0.083717 / 0.424275 (-0.340558) | 0.012466 / 0.007607 (0.004859) | 0.545130 / 0.226044 (0.319085) | 5.478228 / 2.268929 (3.209300) | 2.554169 / 55.444624 (-52.890456) | 2.214703 / 6.876477 (-4.661774) | 2.229997 / 2.142072 (0.087925) | 0.809851 / 4.805227 (-3.995376) | 0.151019 / 6.500664 (-6.349645) | 0.066354 / 0.075469 (-0.009115) |

### Benchmark: benchmark_map_filter.json

| metric | filter | map fast-tokenizer batched | map identity | map identity batched | map no-op batched | map no-op batched numpy | map no-op batched pandas | map no-op batched pytorch | map no-op batched tensorflow |
|--------|---|---|---|---|---|---|---|---|---|
| new / old (diff) | 1.281016 / 1.841788 (-0.560772) | 14.071312 / 8.074308 (5.997004) | 14.682465 / 10.191392 (4.491073) | 0.144197 / 0.680424 (-0.536227) | 0.017088 / 0.534201 (-0.517113) | 0.379049 / 0.579283 (-0.200234) | 0.390713 / 0.434364 (-0.043650) | 0.435804 / 0.540337 (-0.104534) | 0.518895 / 1.386936 (-0.868041) |

</details>
</details>

![](https://cml.dev/watermark.png#fc5c84f36684343bff3e424cb0fd1ac5ecdd66da "CML watermark")