def construct_1d_arraylike_from_scalar(value, length, dtype):
if is_datetime64tz_dtype(dtype):<EOL><INDENT>from pandas import DatetimeIndex<EOL>subarr = DatetimeIndex([value] * length, dtype=dtype)<EOL><DEDENT>elif is_categorical_dtype(dtype):<EOL><INDENT>from pandas import Categorical<EOL>subarr = Categorical([value] * length, dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>if not isinstance(dtype, (np.dtype, type(np.dtype))):<EOL><INDENT>dtype = dtype.dtype<EOL><DEDENT>if length and is_integer_dtype(dtype) and isna(value):<EOL><INDENT>dtype = np.dtype('<STR_LIT>')<EOL><DEDENT>elif isinstance(dtype, np.dtype) and dtype.kind in ("<STR_LIT>", "<STR_LIT:S>"):<EOL><INDENT>dtype = object<EOL>if not isna(value):<EOL><INDENT>value = to_str(value)<EOL><DEDENT><DEDENT>subarr = np.empty(length, dtype=dtype)<EOL>subarr.fill(value)<EOL><DEDENT>return subarr<EOL>
create a np.ndarray / pandas type of specified shape and dtype
filled with values

Parameters
----------
value : scalar value
length : int
dtype : pandas_dtype / np.dtype

Returns
-------
np.ndarray / pandas type of length, filled with value