What does 1 do in X = np.array(df.drop(['label'], 1))? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: What does 1 do in X = np.array(df.drop(['label'], 1))? (/thread-1922.html) |
What does 1 do in X = np.array(df.drop(['label'], 1))? - landlord1984 - Feb-04-2017 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] RE: What does 1 do in X = np.array(df.drop(['label'], 1))? - buran - Feb-04-2017 Actually, that is argument fo df.drop http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html RE: What does 1 do in X = np.array(df.drop(['label'], 1))? - landlord1984 - Feb-04-2017 (Feb-04-2017, 01:19 PM)buran Wrote: Actually, that is argument fo df.drop http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop.html Arha....I need to take a rest. My eye seems not working. |