import pandas as pd import datasets CITATION = """ """ #TODO: There must be other way to refer to file in the repo CSV_URL = "https://huggingface.co/datasets/mwinn99/biovdb_1000/resolve/main/biovdb_1000.csv" class Biovdb(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("1.0.0") def _info(self): return datasets.DatasetInfo( description="Test set of samples from GEO", citation=CITATION, homepage="", features=datasets.Features({ 'metadata': {col: datasets.Value('string') for col in pd.read_csv(CSV_URL, nrows=1).columns[:40]}, 'data': datasets.Sequence(datasets.Value('float32')) }), ) def _split_generators(self, dl_manager): data_fname = dl_manager.download(CSV_URL) data = pd.read_csv(data_fname) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data": data}) ] def _generate_examples(self, data): data = data.infer_objects() metadata_columns = data.columns[:40] expression_columns = data.columns[40:] for idx, row in data.iterrows(): yield idx, { "data": row[expression_columns].astype(float).values.tolist(), "metadata": row[metadata_columns].astype(str).to_dict() } if __name__ == '__main__': ds = datasets.load_dataset("./biovdb_1000.py", split='train')