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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# NUSITS: Nanjing University-Siemens Time Series Corpus
|
| 6 |
+
|
| 7 |
+
This dataset card describes the `main` branch of NUSITS. NUSITS is a large-scale, real-world multivariate time-series corpus for pretraining and benchmarking time-series foundation models (TSFMs). The complete corpus contains around 200 sub-datasets, 2 million original time-series files, 16 billion timesteps, and 142 billion time points across energy, finance, environment, industry, traffic, and other domains.
|
| 8 |
+
|
| 9 |
+
- **Project GitHub:** [to be added](https://github.com/TO_BE_FILLED)
|
| 10 |
+
- **Paper:** [to be added](https://arxiv.org/abs/TO_BE_FILLED)
|
| 11 |
+
|
| 12 |
+
## 📦 Dataset Packaging & Structure
|
| 13 |
+
|
| 14 |
+
The `main` branch contains the full NUSITS corpus in Parquet format. To avoid distributing millions of very small files, the original Parquet files within each sub-dataset have been merged into larger files named `part0.parquet`, `part1.parquet`, and so on.
|
| 15 |
+
|
| 16 |
+
```text
|
| 17 |
+
NUSITS/
|
| 18 |
+
├── ApplianceEnergy/
|
| 19 |
+
│ ├── part0.parquet
|
| 20 |
+
│ ├── meta.json
|
| 21 |
+
│ └── references.bib
|
| 22 |
+
├── Electricity/
|
| 23 |
+
│ ├── part0.parquet
|
| 24 |
+
│ ├── part1.parquet
|
| 25 |
+
│ ├── ...
|
| 26 |
+
│ ├── meta.json
|
| 27 |
+
│ └── references.bib
|
| 28 |
+
└── ...
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
During merging, NUSITS adds an `_original_filename` column to every row. This column stores the stem of the original Parquet filename and makes the merge reversible.
|
| 32 |
+
|
| 33 |
+
> If you need the original one-file-per-series layout, either restore it with the code below or use the [`zipped_version`](https://huggingface.co/datasets/YOUR_HF_NAMESPACE/YOUR_DATASET_NAME/tree/zipped_version) branch, or use the following memory-efficient parsing script.
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
import os
|
| 37 |
+
import pandas as pd
|
| 38 |
+
import pyarrow.parquet as pq
|
| 39 |
+
import gc
|
| 40 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 41 |
+
from tqdm import tqdm
|
| 42 |
+
|
| 43 |
+
# Configure the directory where your downloaded datasets are located, and running the code will parse all the datasets in this directory
|
| 44 |
+
TARGET_ROOTS = ['./NUSITS']
|
| 45 |
+
MAX_WORKERS = 1
|
| 46 |
+
|
| 47 |
+
def restore_single_part_file(args):
|
| 48 |
+
part_file_path, dataset_path = args
|
| 49 |
+
try:
|
| 50 |
+
parquet_file = pq.ParquetFile(part_file_path)
|
| 51 |
+
if '_original_filename' not in parquet_file.schema.names:
|
| 52 |
+
return False, part_file_path
|
| 53 |
+
|
| 54 |
+
for i in range(parquet_file.num_row_groups):
|
| 55 |
+
df_group = parquet_file.read_row_group(i).to_pandas()
|
| 56 |
+
if df_group.empty: continue
|
| 57 |
+
|
| 58 |
+
groups = df_group.groupby('_original_filename', observed=True)
|
| 59 |
+
for original_name, sub_df in groups:
|
| 60 |
+
restore_path = os.path.join(dataset_path, f"{original_name}.parquet")
|
| 61 |
+
|
| 62 |
+
# Clean the data: drop tracking column and all-NaN columns
|
| 63 |
+
clean_df = sub_df.drop(columns=['_original_filename']).dropna(axis=1, how='all')
|
| 64 |
+
|
| 65 |
+
if os.path.exists(restore_path):
|
| 66 |
+
existing_df = pd.read_parquet(restore_path)
|
| 67 |
+
final_df = pd.concat([existing_df, clean_df], ignore_index=True)
|
| 68 |
+
final_df.to_parquet(restore_path, index=False, compression='snappy')
|
| 69 |
+
else:
|
| 70 |
+
clean_df.to_parquet(restore_path, index=False, compression='snappy')
|
| 71 |
+
|
| 72 |
+
del df_group
|
| 73 |
+
gc.collect()
|
| 74 |
+
|
| 75 |
+
return True, part_file_path
|
| 76 |
+
except Exception as e:
|
| 77 |
+
print(f"\n⚠️ Error processing {os.path.basename(part_file_path)}: {e}")
|
| 78 |
+
return False, part_file_path
|
| 79 |
+
|
| 80 |
+
def process_restore(dataset_path):
|
| 81 |
+
part_files = [f for f in os.listdir(dataset_path) if f.startswith('part') and f.endswith('.parquet')]
|
| 82 |
+
if not part_files: return
|
| 83 |
+
|
| 84 |
+
tasks = [(os.path.join(dataset_path, pf), dataset_path) for pf in part_files]
|
| 85 |
+
print(f"🚀 Restoring {os.path.basename(dataset_path)} ({len(part_files)} chunks)...")
|
| 86 |
+
|
| 87 |
+
with tqdm(total=len(tasks), unit="part") as pbar:
|
| 88 |
+
with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
|
| 89 |
+
futures = [executor.submit(restore_single_part_file, task) for task in tasks]
|
| 90 |
+
for future in as_completed(futures):
|
| 91 |
+
success, f_path = future.result()
|
| 92 |
+
if success: os.remove(f_path) # Delete chunk after successful restoration
|
| 93 |
+
pbar.update(1)
|
| 94 |
+
|
| 95 |
+
if __name__ == "__main__":
|
| 96 |
+
for root in TARGET_ROOTS:
|
| 97 |
+
if os.path.exists(root):
|
| 98 |
+
for ds in os.listdir(root):
|
| 99 |
+
ds_path = os.path.join(root, ds)
|
| 100 |
+
if os.path.isdir(ds_path):
|
| 101 |
+
process_restore(ds_path)
|
| 102 |
+
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
## 💻 Quick Start: Hugging Face API
|
| 107 |
+
|
| 108 |
+
If you want to stream or load the dataset directly using the `datasets` library, here is how to load a dataset, extract a specific time series, and clean the formatting artifacts caused by the merging process.
|
| 109 |
+
|
| 110 |
+
```python
|
| 111 |
+
from datasets import load_dataset
|
| 112 |
+
import pandas as pd
|
| 113 |
+
|
| 114 |
+
# 1. Load the dataset (using 'ACSF1' as an example)
|
| 115 |
+
# Replace 'TYM666/test' with the actual repository name if it changes
|
| 116 |
+
dataset = load_dataset("TYM666/test", data_dir="ACSF1", split="train")
|
| 117 |
+
|
| 118 |
+
# Convert to pandas dataframe for easier manipulation
|
| 119 |
+
df = dataset.to_pandas()
|
| 120 |
+
|
| 121 |
+
# 2. Print basic info about the dataset
|
| 122 |
+
unique_files = df['_original_filename'].unique()
|
| 123 |
+
print("\n" + "="*40)
|
| 124 |
+
print("📊 Information of ACSF1 Dataset.")
|
| 125 |
+
print("="*40)
|
| 126 |
+
print(f"🔹 Unique Series: {len(unique_files):,}")
|
| 127 |
+
print(f"🔹 Total Rows: {len(df):,}")
|
| 128 |
+
print(f"🔹 Features: {list(df.columns)}")
|
| 129 |
+
print("="*40 + "\n")
|
| 130 |
+
|
| 131 |
+
# 3. Extract a single time series (e.g., the series originally named '0.parquet')
|
| 132 |
+
sample_file = "0"
|
| 133 |
+
print(f"🔍 sample: extracting [{sample_file}.parquet] ...\n")
|
| 134 |
+
|
| 135 |
+
single_series_df = (
|
| 136 |
+
df[df['_original_filename'] == sample_file]
|
| 137 |
+
.drop(columns=['_original_filename']) # Remove the tracking column
|
| 138 |
+
.dropna(axis=1, how='all') # Remove empty columns generated by schema merging
|
| 139 |
+
.reset_index(drop=True)
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
print(single_series_df.head(5))
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
## Download Data
|
| 147 |
+
|
| 148 |
+
Download only one sub-dataset:
|
| 149 |
+
|
| 150 |
+
```python
|
| 151 |
+
from huggingface_hub import snapshot_download
|
| 152 |
+
|
| 153 |
+
snapshot_download(
|
| 154 |
+
repo_id="YOUR_HF_NAMESPACE/YOUR_DATASET_NAME",
|
| 155 |
+
repo_type="dataset",
|
| 156 |
+
revision="main",
|
| 157 |
+
allow_patterns=["ApplianceEnergy/*"],
|
| 158 |
+
local_dir="NUSITS-main",
|
| 159 |
+
)
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
Download the complete `main` branch:
|
| 163 |
+
|
| 164 |
+
```python
|
| 165 |
+
from huggingface_hub import snapshot_download
|
| 166 |
+
|
| 167 |
+
snapshot_download(
|
| 168 |
+
repo_id="YOUR_HF_NAMESPACE/YOUR_DATASET_NAME",
|
| 169 |
+
repo_type="dataset",
|
| 170 |
+
revision="main",
|
| 171 |
+
local_dir="NUSITS-main",
|
| 172 |
+
)
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
The full corpus is very large. Ensure that enough disk space is available before downloading it.
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
## Other Branches
|
| 179 |
+
|
| 180 |
+
- [`zipped_version`](https://huggingface.co/datasets/YOUR_HF_NAMESPACE/YOUR_DATASET_NAME/tree/zipped_version): Full NUSITS corpus in compressed archives, preserving the original file layout.
|
| 181 |
+
- [`smaller_version`](https://huggingface.co/datasets/YOUR_HF_NAMESPACE/YOUR_DATASET_NAME/tree/smaller_version): Smaller, domain-balanced NUSITS subset in Parquet format.
|
| 182 |
+
- [`recommended_corpus`](https://huggingface.co/datasets/YOUR_HF_NAMESPACE/YOUR_DATASET_NAME/tree/recommended_corpus): Recommended pretraining mixture used in the paper.
|
| 183 |
+
|
| 184 |
+
## License
|
| 185 |
+
|
| 186 |
+
The NUSITS compilation is released under the MIT License. Each source dataset remains governed by its original license, recorded in the corresponding `meta.json`. Users are responsible for reviewing and complying with the terms of every sub-dataset they use.
|
| 187 |
+
|
| 188 |
+
## Citation
|
| 189 |
+
|
| 190 |
+
If you use NUSITS in your research, please cite:
|
| 191 |
+
|
| 192 |
+
```bibtex
|
| 193 |
+
@article{sun2026nusits,
|
| 194 |
+
title = {NUSITS: A Large-scale Real-world Multivariate Corpus for Time Series Foundation Models},
|
| 195 |
+
author = {Sun, Qian and Tian, Yong-Ming and Huang, Jia-Wei and Feng, Cheng and Zhang, Shao-Qun},
|
| 196 |
+
journal = {TO DO},
|
| 197 |
+
year = {2026}
|
| 198 |
+
}
|
| 199 |
+
```
|