code: def one_hot_encode(y: pd.Series) -> pd.DataFrame:
      """One hot encode input pandas series into sparse pandas DataFrame.
  
      Parameters
      ----------
      y
          Pandas Series of strings.
  
      Returns
      --------
      One hot encoded sparse dataframe.
  
      """
      classes = np.unique(y)
      indices = np.searchsorted(classes, y)
      indptr = np.hstack((0, np.cumsum(np.in1d(y, classes))))
      data = np.empty_like(indices)
      data.fill(1)
      return pd.DataFrame.sparse.from_spmatrix(
          sparse.csr_matrix(
              (data, indices, indptr),
              shape=(y.shape[0], classes.shape[0]),
          ),
          index=y.index,
          columns=[str(c) for c in classes],
      )
  
file_path: river/river/naive_bayes/base.py
imports: from __future__ import annotations
  import abc
  import math
  import numpy
  import pandas
  from scipy import sparse, special
  from river import base
label_desc: Use image node_id 2 for calling a global function with example usage: one_hot_encode(y) and returns: pd