LoginSignup
0
0

huggingface の DatasetDict からのデータ選択方法

Last updated at Posted at 2023-05-17

1. はじめに

自分が DatasetDict から特定のファイル, 列を選択するのにちょっと時間がかかったため、やり方を載せておきます

2. やり方

  1. DatasetDict を huggingface 経由でロードする

    from dataser import load_dataset
    
    dataset = load_dataset({dataset_name})
    
  2. データ選択の方法
    特定のファイルを削除したいとき

    # 普通の辞書からの削除方法と一緒
    # 今回は 'garbage_file' という名前のファイルを削除する
    del dataset['garbage_file']
    

    特定の列を削除したいとき

    # 今回は 'garbage_column' という名前の列を削除する
    dataset = dataset.remove_columns('garbage_column')
    

3. 終わりに

huggingface 経由でデータをとることは多々あると思うので参考になればと思います

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0