I have a Pandas dataframe with 10 columns, 9 of which are features to be used to predict the 10th column.
How is it ossible to convert this Pandas dataframe into X and y vectors to use in a linear regression problem?
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
Are you looking for this?
#format the data as a numpy array to feed into the algorithm X = np.asarray([np.asarray(df['Ind1']),np.asarray(df['Ind2']),np.asarray(df['Ind3'])]) y = np.asarray([np.asarray(df['Dep'])])
# array(['a', 'b', 'c'], dtype=object) arr = df.index.to_numpy() # array([1, 2, 3]) arr = df['A'].to_numpy()