# Got wrong row number of dataset viewer

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%3E%5C
**Category:** 🤗Hub\
**Created:** [March 12, 2024, 7:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132 "2024-03-12T19:12:33Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![shizue](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shizue/32/24696_2.png) [@shizue](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fshizue)%5C
**Post date:** [March 12, 2024, 7:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F1 "2024-03-12T19:12:33Z")

</div>

Hi,  
I’m experiencing a strange problem. I have a dataset with the type `DatasetDict`, here is its basic info:

```python
DatasetDict({
    train: Dataset({
        features: ['subject', 'grade', 'skill', 'pic_choice', 'pic_prob', 'problem', 'problem_pic', 'choices', 'choices_pic', 'answer_idx'],
        num_rows: 1000
    })
    valid: Dataset({
        features: ['subject', 'grade', 'skill', 'pic_choice', 'pic_prob', 'problem', 'problem_pic', 'choices', 'choices_pic', 'answer_idx'],
        num_rows: 1000
    })
    test: Dataset({
        features: ['subject', 'grade', 'skill', 'pic_choice', 'pic_prob', 'problem', 'problem_pic', 'choices', 'choices_pic', 'answer_idx'],
        num_rows: 1000
    })
})

```

I use the following code to upload it into the hub:

```python
dataset_small.push_to_hub(
    hub_path, private=False, commit_message="Upload example dataset."
)

```

After it is converted into parquet and uploaded into the hub, the dataset viewer shows the wrong number of rows:

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/9/9/9955e4a03fe8276cc50a9c49290800c0f3172a30.png)

But if I use the following code to download the dataset:

```python
from datasets import load_dataset
dataset_demo = load_dataset(hub_path)
print(dataset_demo)

```

I will get the correct info (1k/1k/1k for each split and 3k in total).

Is there something wrong with my usage of `datasets` and huggingface hub?

Update:  
I also got the wrong number when I used the datasets-server API in [Get the number of rows and the size in bytes](https://huggingface.co/docs/datasets-server/size?code=curl) to get the dataset size. It seems that the backend of the datasets-server API has some bugs.

Looking forward to any suggestions and thanks a lot in advance!

---

<div class="post-metadata">

**Author:** ![severo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/severo/32/27449_2.png) [@severo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsevero)%5C
**Post date:** [March 13, 2024, 9:49am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F3 "2024-03-13T09:49:56Z")

</div>

well spotted, thanks for opening the issue [The API returns the wrong row number · Issue #2581 · huggingface/datasets-server · GitHub](https://github.com/huggingface/datasets-server/issues/2581), we’re on it

---

<div class="post-metadata">

**Author:** ![severo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/severo/32/27449_2.png) [@severo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsevero)%5C
**Post date:** [March 13, 2024, 10:58am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F4 "2024-03-13T10:58:25Z")

</div>

fixed. Thanks again for the investigation!

---

<div class="post-metadata">

**Author:** ![shizue](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shizue/32/24696_2.png) [@shizue](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fshizue)%5C
**Post date:** [March 13, 2024, 12:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F5 "2024-03-13T12:06:22Z")

</div>

Thank you for the reply and fix~

---

<div class="post-metadata">

**Author:** ![animepfp](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/animepfp/32/28567_2.png) [@animepfp](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanimepfp)%5C
**Post date:** [June 24, 2024, 3:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F6 "2024-06-24T03:23:05Z")

</div>

Still displaying the wrong number of rows: [CaptionEmporium/coyo-hd-11m-llavanext · Datasets at Hugging Face](https://huggingface.co/datasets/CaptionEmporium/coyo-hd-11m-llavanext)

```py
>>> len(df)
11397144

```

It is also autogenerating parquet files for the parquets I uploaded?

---

<div class="post-metadata">

**Author:** ![severo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/severo/32/27449_2.png) [@severo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsevero)%5C
**Post date:** [June 24, 2024, 9:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F7 "2024-06-24T09:37:28Z")

</div>

@lhoestq:

I guess we regenerate Parquet files because of the different row group size? The number of rows is estimated on the autogenerated Parquet files, which is why it’s not exact. In this case, we could get the exact value very easily, maybe something to fix?

---

<div class="post-metadata">

**Author:** ![animepfp](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/animepfp/32/28567_2.png) [@animepfp](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanimepfp)%5C
**Post date:** [June 24, 2024, 8:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F8 "2024-06-24T20:53:36Z")

</div>

I used the `datasets` library, uploaded it to `data`, and it _still_ doesn’t give the right number of rows.

```py
import gc
import orjsonl
foo = orjsonl.load('train.jsonl.gz')
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
df = pd.DataFrame(foo)
table = pa.Table.from_pandas(df)
pq.write_table(table, './train_full.parquet')
del foo, df, table
gc.collect()
from datasets import Dataset
dataset = Dataset.from_parquet('./train_full.parquet')
dataset.save_to_disk('./huggingface')

```

---

<div class="post-metadata">

**Author:** ![severo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/severo/32/27449_2.png) [@severo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsevero)%5C
**Post date:** [June 25, 2024, 12:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F9 "2024-06-25T12:29:18Z")

</div>

The repository currently contains three kinds of data: parquet files, json.gz, and arrow files. Moreover, the README YAML does not contain configuration to help us determine which data files should be used for which split, so: it’s best guess using heuristics.

 ![Capture d’écran 2024-06-25 à 14.26.09](https://us1.discourse-cdn.com/hellohellohello/original/3X/a/8/a8e10bcfdad791acaf374046ea102c6385c3c5db.png)  
 ![Capture d’écran 2024-06-25 à 14.26.19](https://us1.discourse-cdn.com/hellohellohello/original/3X/7/4/7463a96975c64d3fea273cec8629a7082af4973a.png)

To get the expected results, you can add a `configs:` field in the README frontmatter. We have detailed documentation pages at [Data files Configuration](https://huggingface.co/docs/hub/datasets-data-files-configuration), and example datasets with the supported structures/configurations that you can replicate at [datasets-examples (Datasets examples)](https://huggingface.co/datasets-examples).

I hope it helps.

---

<div class="post-metadata">

**Author:** ![animepfp](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/animepfp/32/28567_2.png) [@animepfp](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanimepfp)%5C
**Post date:** [June 25, 2024, 1:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F10 "2024-06-25T13:15:18Z")

</div>

> I hope it helps.

I believe so. Just for people Googling in the future.

For a dataset repository to use the right data, you must consider:

- You must have a configuration that is YAML instead a README markdown document that points to your training splits. The `README.md` document is not prepared by `save_to_disk`.
- `save_to_disk` will create a `dataset_info.json` and `state.json`, but that doesn’t do anything as far as the UI is concerned.
- The UI will ignore the file extension/files (`.arrow`) that are produced by `save_to_disk`and instead relies on a hierarchy of extensions to find while crawling the repository.

Do I have this correct? This was unexpected for myself, but if this is the way it works this is the way it works.

I have updated the README.md to reflect the arrow files, but it still reports the wrong number of rows:

[https://huggingface.co/datasets/CaptionEmporium/coyo-hd-11m-llavanext/raw/main/README.md](https://huggingface.co/datasets/CaptionEmporium/coyo-hd-11m-llavanext/raw/main/README.md)

> **[CaptionEmporium/coyo-hd-11m-llavanext · Datasets at Hugging Face](https://huggingface.co/datasets/CaptionEmporium/coyo-hd-11m-llavanext)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![animepfp](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/animepfp/32/28567_2.png) [@animepfp](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanimepfp)%5C
**Post date:** [June 25, 2024, 6:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F11 "2024-06-25T18:48:42Z")

</div>

I deleted the data folder and re-uploaded only the arrow files, and only the arrow files listed in the config. That seems to have broken the auto-parquet bot.

```auto
Job manager crashed while running this job (missing heartbeats).

Error code: JobManagerCrashedError

```

At this point I’m not sure what it going wrong, but my hope without delving deeply is that at least loading the dataset using the HF library works.

---

<div class="post-metadata">

**Author:** ![severo](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/severo/32/27449_2.png) [@severo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsevero)%5C
**Post date:** [June 26, 2024, 8:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F12 "2024-06-26T08:52:09Z")

</div>

Note that `.push_to_hub`([Main classes](https://huggingface.co/docs/datasets/v2.20.0/en/package_reference/main_classes#datasets.DatasetDict.push_to_hub)) does all the job: upload the Dataset object to a repository on the Hub, in Parquet files, and it prepares the README.md file accordingly.

For dataset-info.json and state.json, and more generally on the recommended way to prepare your dataset, I’ll let @lhoestq or @albertvillanova answer, as I’m not an expert.

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [June 26, 2024, 1:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F13 "2024-06-26T13:11:09Z")

</div>

dataset-info.json and state.json are not meant to be uploaded to HF

They are part of the `save_to_disk()` output which is meant for local Arrow serialization of a dataset to be reused in the same environment.

You should use `push_to_hub()` if you want to upload on HF

---

<div class="post-metadata">

**Author:** ![monperrus](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/monperrus/32/53792_2.png) [@monperrus](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmonperrus)%5C
**Post date:** [September 13, 2025, 4:57am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F14 "2025-09-13T04:57:05Z")

</div>

Hi all,

For [ASSERT-KTH/DISL · Datasets at Hugging Face](https://huggingface.co/datasets/ASSERT-KTH/DISL/viewer/raw) the number of raws shown is incorrect:

Expected Number: 3.3M (3,298,271)

Actual Number: 210k rows

How to fix this?

Thanks!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [September 13, 2025, 5:52am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fgot-wrong-row-number-of-dataset-viewer%2F77132%2F15 "2025-09-13T05:52:07Z")

</div>

I think [it’s a size limit](https://huggingface.co/docs/hub/en/datasets-viewer#large-scale-datasets) rather than a bug…
