1

I have a dataset as pandas dataframe that needs to be divided into feature set and labels. as of now, I am dividing the columns as below,

features = df2.drop('case_of_injury_group', 1)
labels = df2['case_of_injury_group']

but the shape of labels is not as what I expected,

features.shape

give (39778, 12) and

labels.shape

gives (39778, ) but I want it as (39778, 1). Please let me know what i am doing wrong here

Sbk3824
  • 1,229
  • 1
  • 14
  • 24

1 Answers1

1

If want one column DataFrame select by one element nested list:

labels = df2[['case_of_injury_group']]
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252