Fix incorrect rank value in data splitting
State: closed | Author: yzhangcs (CONTRIBUTOR)

Fix #6990.

Comments: Sure~

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/datasets/pr_6994). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

<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.005538 / 0.011353 (-0.005815) | 0.003997 / 0.011008 (-0.007011) | 0.063444 / 0.038508 (0.024935) | 0.032552 / 0.023109 (0.009442) | 0.266574 / 0.275898 (-0.009324) | 0.282841 / 0.323480 (-0.040639) | 0.004279 / 0.007986 (-0.003706) | 0.002788 / 0.004328 (-0.001540) | 0.049226 / 0.004250 (0.044976) | 0.044688 / 0.037052 (0.007636) | 0.275464 / 0.258489 (0.016975) | 0.305278 / 0.293841 (0.011437) | 0.030097 / 0.128546 (-0.098450) | 0.012237 / 0.075646 (-0.063410) | 0.205526 / 0.419271 (-0.213745) | 0.036145 / 0.043533 (-0.007388) | 0.267395 / 0.255139 (0.012256) | 0.289149 / 0.283200 (0.005949) | 0.019044 / 0.141683 (-0.122639) | 1.162294 / 1.452155 (-0.289861) | 1.183642 / 1.492716 (-0.309074) |

### 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.139125 / 0.018006 (0.121119) | 0.301743 / 0.000490 (0.301253) | 0.000260 / 0.000200 (0.000061) | 0.000053 / 0.000054 (-0.000001) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.019494 / 0.037411 (-0.017917) | 0.063078 / 0.014526 (0.048552) | 0.076989 / 0.176557 (-0.099567) | 0.121363 / 0.737135 (-0.615773) | 0.080040 / 0.296338 (-0.216298) |

### 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.284401 / 0.215209 (0.069192) | 2.805397 / 2.077655 (0.727742) | 1.555609 / 1.504120 (0.051489) | 1.405662 / 1.541195 (-0.135533) | 1.459492 / 1.468490 (-0.008999) | 0.718376 / 4.584777 (-3.866401) | 2.395918 / 3.745712 (-1.349794) | 2.976753 / 5.269862 (-2.293108) | 1.883938 / 4.565676 (-2.681738) | 0.078867 / 0.424275 (-0.345408) | 0.005207 / 0.007607 (-0.002400) | 0.335178 / 0.226044 (0.109133) | 3.313414 / 2.268929 (1.044485) | 1.856929 / 55.444624 (-53.587696) | 1.565319 / 6.876477 (-5.311158) | 1.592723 / 2.142072 (-0.549350) | 0.793621 / 4.805227 (-4.011606) | 0.134208 / 6.500664 (-6.366456) | 0.042853 / 0.075469 (-0.032616) |

### 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) | 0.981553 / 1.841788 (-0.860235) | 11.810438 / 8.074308 (3.736130) | 9.529874 / 10.191392 (-0.661518) | 0.142216 / 0.680424 (-0.538207) | 0.014303 / 0.534201 (-0.519898) | 0.304600 / 0.579283 (-0.274684) | 0.261869 / 0.434364 (-0.172495) | 0.347301 / 0.540337 (-0.193036) | 0.437395 / 1.386936 (-0.949541) |

</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.005881 / 0.011353 (-0.005472) | 0.004039 / 0.011008 (-0.006969) | 0.050241 / 0.038508 (0.011733) | 0.032670 / 0.023109 (0.009561) | 0.264940 / 0.275898 (-0.010959) | 0.287105 / 0.323480 (-0.036374) | 0.004844 / 0.007986 (-0.003142) | 0.002867 / 0.004328 (-0.001462) | 0.048083 / 0.004250 (0.043833) | 0.040965 / 0.037052 (0.003913) | 0.274390 / 0.258489 (0.015901) | 0.312107 / 0.293841 (0.018266) | 0.031714 / 0.128546 (-0.096832) | 0.012603 / 0.075646 (-0.063043) | 0.060698 / 0.419271 (-0.358573) | 0.033130 / 0.043533 (-0.010402) | 0.264444 / 0.255139 (0.009305) | 0.282797 / 0.283200 (-0.000403) | 0.027872 / 0.141683 (-0.113811) | 1.139026 / 1.452155 (-0.313129) | 1.181431 / 1.492716 (-0.311285) |

### 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.097314 / 0.018006 (0.079308) | 0.301326 / 0.000490 (0.300836) | 0.000215 / 0.000200 (0.000015) | 0.000049 / 0.000054 (-0.000005) |

### Benchmark: benchmark_indices_mapping.json

| metric | select | shard | shuffle | sort | train_test_split |
|--------|---|---|---|---|---|
| new / old (diff) | 0.023394 / 0.037411 (-0.014018) | 0.076270 / 0.014526 (0.061744) | 0.089065 / 0.176557 (-0.087491) | 0.129996 / 0.737135 (-0.607139) | 0.089642 / 0.296338 (-0.206697) |

### 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.295390 / 0.215209 (0.080181) | 2.877849 / 2.077655 (0.800194) | 1.537129 / 1.504120 (0.033009) | 1.409441 / 1.541195 (-0.131754) | 1.432468 / 1.468490 (-0.036023) | 0.718054 / 4.584777 (-3.866722) | 0.930872 / 3.745712 (-2.814841) | 2.841028 / 5.269862 (-2.428834) | 1.921990 / 4.565676 (-2.643686) | 0.077638 / 0.424275 (-0.346637) | 0.005494 / 0.007607 (-0.002113) | 0.336331 / 0.226044 (0.110287) | 3.330490 / 2.268929 (1.061561) | 1.887994 / 55.444624 (-53.556630) | 1.593332 / 6.876477 (-5.283144) | 1.726956 / 2.142072 (-0.415116) | 0.783612 / 4.805227 (-4.021615) | 0.129926 / 6.500664 (-6.370738) | 0.040792 / 0.075469 (-0.034677) |

### 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) | 0.980274 / 1.841788 (-0.861514) | 12.193871 / 8.074308 (4.119563) | 10.348934 / 10.191392 (0.157542) | 0.141584 / 0.680424 (-0.538840) | 0.015737 / 0.534201 (-0.518464) | 0.300725 / 0.579283 (-0.278558) | 0.127190 / 0.434364 (-0.307174) | 0.341142 / 0.540337 (-0.199196) | 0.459523 / 1.386936 (-0.927413) |

</details>
</details>

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