def transform_array_to_list(array):
 if ((array.dtype.kind in ('u', 'i', 'f')) and (~ np.isfinite(array)).any()):
  transformed = array.astype('object')
  transformed[np.isnan(array)] = 'NaN'
  transformed[np.isposinf(array)] = 'Infinity'
  transformed[np.isneginf(array)] = '-Infinity'
  return transformed.tolist()
 return array.tolist()

def transform_array_to_list ( array ) : if ( ( array . dtype . kind in ( 'u' , 'i' , 'f' ) ) and ( ~ np . isfinite ( array ) ) . any ( ) ) : transformed = array . astype ( 'object' ) transformed [ np . isnan ( array ) ] = 'NaN' transformed [ np . isposinf ( array ) ] = 'Infinity' transformed [ np . isneginf ( array ) ] = '-Infinity' return transformed . tolist ( ) return array . tolist ( )
transforms a numpy array into a list of values args: array : the numpy array series to transform returns: list or dict .