Python Forum
What does 1 do in X = np.array(df.drop(['label'], 1))?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does 1 do in X = np.array(df.drop(['label'], 1))?
#1
X = np.array(df.drop(['label'], 1))
I understand this code is to convert a Pandas's dataframe into a numpy array without a column labelled as "label".
But what is 1 doing here?

Accoding to numpy array's definition:numpy.array(object, dtype=None, copy=True, order='K', subok=False, ndmin=0)

it seems is about datatype? I have tried to delete 1, this will produce errors. So 1 is essential here.

On the other hand, if I convert one dataframe's column to a numpy array, it works without a second argument:


y = np.array(df['label'])
Thanks,

L
[/url][url=https://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html#numpy.array]
Reply


Messages In This Thread
What does 1 do in X = np.array(df.drop(['label'], 1))? - by landlord1984 - Feb-04-2017, 01:15 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020