File size: 2,034 Bytes
f83bb36 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import json
import datasets
from datasets import load_dataset, Dataset, DatasetDict, Features, Value
class MyDatasetConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super(MyDatasetConfig, self).__init__(**kwargs)
class MyDataset(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
MyDatasetConfig(name="master_device-attributes", version=datasets.Version("1.0.0"), description="Master Device Attributes."),
]
def _info(self):
return datasets.DatasetInfo(
features=datasets.Features({
"Qubit": datasets.Value("int32"),
"F_res_GHz": datasets.Value("string"),
"F_01_GHz": datasets.Value("string"),
"Alpha_2pi_MHz": datasets.Value("string"),
"Punchout_shift_MHz": datasets.Value("string"),
"Extracted_g_MHz": datasets.Value("string"),
"Estimated_Dispersive_Shift_KHz": datasets.Value("string"),
"L_j_nH": datasets.Value("string"),
"kappa": datasets.Value("string"),
"notes": datasets.Value("string")
}),
)
common_festures = Features({
"Qubit": Value("int32"),
"F_res_GHz": Value("string"),
"F_01_GHz": Value("string"),
"Alpha_2pi_MHz": Value("string"),
"Punchout_shift_MHz": Value("string"),
"Extracted_g_MHz": Value("string"),
"Estimated_Dispersive_Shift_KHz": Value("string"),
"L_j_nH": Value("string"),
"kappa": Value("string"),
"notes": Value("string")
})
json_file1 = Dataset.from_json(r'C:\Users\Liz\OneDrive\Documents\HuggingFace\SQuADDS_DB\master_device-attributes.json', features=features)
desired_order = ['design_code', 'contrib_info', 'measured_results', 'sim_results', 'notes']
json_file1 = json_file1.set_format(type=None, columns=desired_order)
# Save the DatasetDict to a new dataset on Hugging Face Hub
dataset_dict.push_to_hub("elizabethkunz/test_branch") |