code: def NdarrayToEntry(self, x):
      
      row_counts = []
      for row in x:
        try:
          rc = np.count_nonzero(~np.isnan(row))
          if rc != 0:
            row_counts.append(rc)
        except TypeError:
          try:
            row_counts.append(row.size)
          except AttributeError:
            row_counts.append(1)
  
      data_type = self.DtypeToType(x.dtype)
      converter = self.DtypeToNumberConverter(x.dtype)
      flattened = x.ravel()
      orig_size = len(flattened)
  
      # Remove all None and nan values and count how many were removed.
      flattened = flattened[flattened != np.array(None)]
      if converter:
        flattened = converter(flattened)
      if data_type == self.fs_proto.STRING:
        flattened_temp = []
        for x in flattened:
          try:
            if str(x) != 'nan':
              flattened_temp.append(x)
          except UnicodeEncodeError:
            if x.encode('utf-8') != 'nan':
              flattened_temp.append(x)
        flattened = flattened_temp
      else:
        flattened = flattened[~np.isnan(flattened)].tolist()
      missing = orig_size - len(flattened)
      return {
          'vals': flattened,
          'counts': row_counts,
          'missing': missing,
          'type': data_type
      }
docs: Converts an ndarray to the Entry format.