def init_dict(data, index, columns, dtype=None):
if columns is not None:<EOL><INDENT>from pandas.core.series import Series<EOL>arrays = Series(data, index=columns, dtype=object)<EOL>data_names = arrays.index<EOL>missing = arrays.isnull()<EOL>if index is None:<EOL><INDENT>index = extract_index(arrays[~missing])<EOL><DEDENT>else:<EOL><INDENT>index = ensure_index(index)<EOL><DEDENT>if missing.any() and not is_integer_dtype(dtype):<EOL><INDENT>if dtype is None or np.issubdtype(dtype, np.flexible):<EOL><INDENT>nan_dtype = object<EOL><DEDENT>else:<EOL><INDENT>nan_dtype = dtype<EOL><DEDENT>val = construct_1d_arraylike_from_scalar(np.nan, len(index),<EOL>nan_dtype)<EOL>arrays.loc[missing] = [val] * missing.sum()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>keys = com.dict_keys_to_ordered_list(data)<EOL>columns = data_names = Index(keys)<EOL>arrays = [data[k] if not is_datetime64tz_dtype(data[k]) else<EOL>data[k].copy(deep=True) for k in keys]<EOL><DEDENT>return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)<EOL>
Segregate Series based on type and coerce into matrices.
Needs to handle a lot of exceptional cases.