Convert Select Columns in Pandas Dataframe to Numpy Array

前端 未结 6 479
南方客
南方客 2020-12-13 02:05

I would like to convert everything but the first column of a pandas dataframe into a numpy array. For some reason using the columns= parameter of DataFram

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 02:27

    the easy way is the "values" property df.iloc[:,1:].values

    a=df.iloc[:,1:]
    b=df.iloc[:,1:].values
    
    print(type(df))
    print(type(a))
    print(type(b))
    

    so, you can get type

    
    
    
    

提交回复
热议问题