code: def _hfd5_from_dataframe(data, outputfilename):
      ratings = coo_matrix(
          (
              data["rating"].astype(np.float32),
              (
                  data["item"].cat.codes.copy(),
                  data["user"].cat.codes.copy(),
              ),
          )
      ).tocsr()
      with h5py.File(outputfilename, "w") as f:
          g = f.create_group("item_user_ratings")
          g.create_dataset("data", data=ratings.data)
          g.create_dataset("indptr", data=ratings.indptr)
          g.create_dataset("indices", data=ratings.indices)
  
file_path: implicit/implicit/datasets/reddit.py
imports: import logging
  import os
  import time
  import h5py
  import numpy
  from scipy.sparse import coo_matrix, csr_matrix
  from implicit.datasets import _download
label_desc: Use image node_id 4 for calling a global function with example usage: _hfd5_from_dataframe(data, outputfilename) without return types