original_docstring: One hot encode input pandas series into sparse pandas DataFrame.
  
      Parameters
      ----------
      y
          Pandas Series of strings.
  
      Returns
      --------
      One hot encoded sparse dataframe.
  
      
docstring: One hot encode input pandas series into sparse pandas DataFrame.
  Parameters
  
  y
  Pandas Series of strings.
  
  Returns
  
  One hot encoded sparse dataframe.
docstring_tokens: One hot encode input pandas series into sparse pandas DataFrame . Parameters y Pandas Series of strings . Returns One hot encoded sparse dataframe .
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],
      )
code_tokens: def one_hot_encode ( y : pd . Series ) -> pd . 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 ] , )
short_docstring: One hot encode input pandas series into sparse pandas DataFrame.
short_docstring_tokens: One hot encode input pandas series into sparse pandas DataFrame .
comment: """One hot encode input pandas series into sparse pandas DataFrame.
  
      Parameters
      ----------
      y
          Pandas Series of strings.
  
      Returns
      --------
      One hot encoded sparse dataframe.
  
      """