Pandas Dataframe数据转换为二维数组array

一个Dataframe如下:

    age  astigmatic  lenses_target  prescript  tearRate
0     2           0              1          1         1
1     2           0              2          1         0
2     2           1              1          1         1
3     2           1              0          1         0
4     2           0              1          0         1
5     2           0              2          0         0

使用语句arr=pd.values后:

array([[2, 0, 1, 1, 1],
       [2, 0, 2, 1, 0],
       [2, 1, 1, 1, 1],
       [2, 1, 0, 1, 0],
       [2, 0, 1, 0, 1],
       [2, 0, 2, 0, 0]])

猜你喜欢

转载自blog.csdn.net/dta0502/article/details/83829900
今日推荐