def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False):
subarr = np.array(values, dtype=dtype, copy=copy)<EOL>if dtype is not None and dtype.kind in ("<STR_LIT>", "<STR_LIT:S>"):<EOL><INDENT>na_values = isna(values)<EOL>subarr2 = subarr.astype(object)<EOL>subarr2[na_values] = np.asarray(values, dtype=object)[na_values]<EOL>subarr = subarr2<EOL><DEDENT>return subarr<EOL>
Construct a new ndarray, coercing `values` to `dtype`, preserving NA.

Parameters
----------
values : Sequence
dtype : numpy.dtype, optional
copy : bool, default False
    Note that copies may still be made with ``copy=False`` if casting
    is required.

Returns
-------
arr : ndarray[dtype]

Examples
--------
>>> np.array([1.0, 2.0, None], dtype='str')
array(['1.0', '2.0', 'None'], dtype='<U4')

>>> construct_1d_ndarray_preserving_na([1.0, 2.0, None], dtype='str')