def convert_input_vector(y, index):
if y is None:<EOL><INDENT>return None<EOL><DEDENT>if isinstance(y, pd.Series):<EOL><INDENT>return y<EOL><DEDENT>elif isinstance(y, np.ndarray):<EOL><INDENT>if len(np.shape(y))==<NUM_LIT:1>:  <EOL><INDENT>return pd.Series(y, name='<STR_LIT:target>', index=index)<EOL><DEDENT>elif len(np.shape(y))==<NUM_LIT:2> and np.shape(y)[<NUM_LIT:0>]==<NUM_LIT:1>:  <EOL><INDENT>return pd.Series(y[<NUM_LIT:0>, :], name='<STR_LIT:target>', index=index)<EOL><DEDENT>elif len(np.shape(y))==<NUM_LIT:2> and np.shape(y)[<NUM_LIT:1>]==<NUM_LIT:1>:  <EOL><INDENT>return pd.Series(y[:, <NUM_LIT:0>], name='<STR_LIT:target>', index=index)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % (str(np.shape(y))))<EOL><DEDENT><DEDENT>elif np.isscalar(y):<EOL><INDENT>return pd.Series([y], name='<STR_LIT:target>', index=index)<EOL><DEDENT>elif isinstance(y, list):<EOL><INDENT>if len(y)==<NUM_LIT:0> or (len(y)><NUM_LIT:0> and not isinstance(y[<NUM_LIT:0>], list)): <EOL><INDENT>return pd.Series(y, name='<STR_LIT:target>', index=index)<EOL><DEDENT>elif len(y)><NUM_LIT:0> and isinstance(y[<NUM_LIT:0>], list) and len(y[<NUM_LIT:0>])==<NUM_LIT:1>: <EOL><INDENT>flatten = lambda y: [item for sublist in y for item in sublist]<EOL>return pd.Series(flatten(y), name='<STR_LIT:target>', index=index)<EOL><DEDENT>elif len(y)==<NUM_LIT:1> and isinstance(y[<NUM_LIT:0>], list): <EOL><INDENT>return pd.Series(y[<NUM_LIT:0>], name='<STR_LIT:target>', index=index)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>elif isinstance(y, pd.DataFrame):<EOL><INDENT>if len(list(y))==<NUM_LIT:0>: <EOL><INDENT>return pd.Series(y, name='<STR_LIT:target>')<EOL><DEDENT>if len(list(y))==<NUM_LIT:1>: <EOL><INDENT>return y.iloc[:, <NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % (str(y.shape)))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return pd.Series(y, name='<STR_LIT:target>', index=index)<EOL><DEDENT>
Unite target data type into a Series.
If the target is a Series or a DataFrame, we preserve its index.
But if the target does not contain index attribute, we use the index from the argument.