微风轻轻吹拂
2021-05-20 14:38
采纳率: 100%
浏览 116

机器学习:划分训练集与测试集

下面是我今天做题遇到的问题,在划分数据集的时候,输出结果和要求输出结果不匹配。我的输出结果是全部输出,而要求输出的只输出了前2个和后2个。可是我查了很多博客,都没有说明中间的数据怎么可以把它省略掉。

我的代码如下

import pandas as pd
from sklearn import model_selection

#*************** BEIGN ******************
# 使用pandas库的read_csv读入毒蘑菇数据集(./data/mushrooms.csv)
data = pd.read_csv('./data/mushrooms.csv')
# 划分训练集和测试集,其中70%的数据用于训练,30%的数据用于测试
y=data.iloc[:,22]
X=data.iloc[:,0:22]
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=0.3, random_state=0)
print(X_train,y_train)
print(X_test,y_test)
#**************** END *******************

要求输出结果

cap-shape  cap-surface   ...     population  habitat
5314          2            3   ...              4        0
2075          2            3   ...              2        2
5165          3            3   ...              3        0
1155          0            2   ...              3        2
4448          2            2   ...              5        0
1045          2            3   ...              3        0
3181          2            0   ...              4        6
3225          3            0   ...              5        6
1083          3            0   ...              3        0
6239          3            3   ...              4        6
4700          3            2   ...              4        3
2769          2            0   ...              5        6
5020          3            3   ...              4        4
1302          3            3   ...              3        0
2604          3            0   ...              4        6
4864          3            2   ...              5        0
2058          2            0   ...              0        0
6346          3            3   ...              4        1
376           5            0   ...              5        4
7403          4            2   ...              4        1
873           2            0   ...              4        6
6459          3            3   ...              4        6
6266          3            2   ...              4        3
4911          3            3   ...              1        5
2284          2            2   ...              5        6
5292          2            2   ...              4        6
5544          4            2   ...              1        5
5486          2            2   ...              5        3
2148          3            0   ...              5        6
607           3            2   ...              5        0
...         ...          ...   ...            ...      ...
6216          2            2   ...              4        1
2893          2            2   ...              4        6
537           5            0   ...              4        4
1701          3            3   ...              3        0
2897          3            0   ...              4        6
7768          4            2   ...              4        3
2222          2            2   ...              4        6
2135          2            2   ...              5        6
2599          2            2   ...              4        6
7654          4            3   ...              4        3
705           3            2   ...              5        3
6458          4            2   ...              4        1
3468          2            0   ...              4        6
6744          2            0   ...              3        0
7640          0            3   ...              3        0
7238          4            2   ...              4        3
6743          3            3   ...              4        6
5924          3            2   ...              5        6
5874          2            2   ...              1        5
4373          3            0   ...              5        0
7891          4            2   ...              4        3
1033          3            0   ...              3        0
7527          4            2   ...              4        6
5827          3            3   ...              4        0
4859          3            2   ...              1        5
4931          2            2   ...              1        5
3264          2            0   ...              5        3
1653          2            3   ...              3        0
2607          3            0   ...              4        6
2732          2            2   ...              5        6

[5686 rows x 22 columns] 5314    1
2075    0
5165    1
1155    0
4448    1
1045    0
3181    1
3225    0
1083    0
6239    1
4700    1
2769    0
5020    1
1302    0
2604    0
4864    1
2058    0
6346    1
376     0
7403    1
873     0
6459    1
6266    1
4911    0
2284    0
5292    1
5544    0
5486    1
2148    0
607     0
       ..
6216    1
2893    0
537     0
1701    0
2897    0
7768    1
2222    0
2135    0
2599    0
7654    1
705     0
6458    1
3468    1
6744    0
7640    0
7238    1
6743    1
5924    1
5874    0
4373    1
7891    1
1033    0
7527    1
5827    1
4859    0
4931    0
3264    1
1653    0
2607    0
2732    0
Name: class, Length: 5686, dtype: int64
      cap-shape  cap-surface   ...     population  habitat
380           2            2   ...              3        4
3641          3            2   ...              5        6
273           2            2   ...              2        2
1029          2            3   ...              0        0
684           2            0   ...              4        6
2899          3            2   ...              4        6
1568          3            3   ...              4        4
6126          3            3   ...              4        1
2267          2            2   ...              4        6
4030          2            2   ...              5        6
5481          4            3   ...              1        5
5010          2            2   ...              1        5
1140          3            0   ...              0        0
49            3            2   ...              3        3
888           2            2   ...              5        3
4816          3            0   ...              4        3
2676          2            0   ...              4        6
1916          3            2   ...              4        4
1454          2            3   ...              0        0
2030          2            2   ...              4        6
3443          2            0   ...              4        6
3608          3            0   ...              5        3
5870          3            2   ...              5        0
7145          2            2   ...              4        1
4978          2            2   ...              4        6
4136          2            0   ...              5        6
1103          2            2   ...              3        0
7946          2            2   ...              4        3
2164          3            0   ...              5        6
5129          2            3   ...              4        0
...         ...          ...   ...            ...      ...
5790          2            2   ...              4        1
7608          4            2   ...              4        1
238           2            2   ...              3        0
1524          2            3   ...              0        0
4788          3            2   ...              4        6
2165          2            0   ...              5        6
4218          3            0   ...              5        0
4285          2            0   ...              5        6
1828          2            3   ...              0        0
2643          3            2   ...              4        6
7652          3            3   ...              1        1
7625          3            2   ...              4        6
6925          3            2   ...              4        6
17            2            3   ...              3        0
7494          3            2   ...              4        1
5560          2            3   ...              4        0
3432          2            0   ...              4        3
5281          3            2   ...              1        1
2872          2            2   ...              5        6
2368          2            2   ...              4        6
965           3            3   ...              3        0
172           2            0   ...              4        6
1428          3            2   ...              3        3
483           3            0   ...              5        4
5221          2            2   ...              1        5
520           2            3   ...              2        2
36            5            0   ...              4        4
7959          4            2   ...              4        1
6520          2            2   ...              4        3
6005          3            2   ...              4        6

[2438 rows x 22 columns] 380     1
3641    0
273     0
1029    0
684     0
2899    0
1568    1
6126    1
2267    0
4030    1
5481    0
5010    0
1140    0
49      0
888     0
4816    1
2676    0
1916    1
1454    0
2030    0
3443    1
3608    1
5870    1
7145    1
4978    1
4136    1
1103    1
7946    0
2164    0
5129    1
       ..
5790    1
7608    1
238     0
1524    0
4788    0
2165    0
4218    1
4285    1
1828    0
2643    0
7652    0
7625    1
6925    1
17      1
7494    1
5560    1
3432    1
5281    1
2872    0
2368    0
965     0
172     0
1428    0
483     0
5221    0
520     0
36      0
7959    1
6520    1
6005    1
Name: class, Length: 2438, dtype: int64

我自己的实际输出结果

 cap-shape  cap-surface  cap-color  bruises  odor  gill-attachment  \
5314          2            3          8        1     4                1   
2075          2            3          9        1     1                1   
5165          3            3          8        1     4                1   
1155          0            2          8        1     0                1   
4448          2            2          9        0     4                1   
1045          2            3          8        1     0                1   
3181          2            0          5        0     2                1   
3225          3            0          3        1     6                1   
1083          3            0          3        0     6                1   
6239          3            3          0        0     3                1   
4700          3            2          9        0     4                1   
2769          2            0          3        1     6                1   
5020          3            3          8        1     4                1   
1302          3            3          8        0     6                1   
2604          3            0          0        1     6                1   
4864          3            2          3        0     4                1   
2058          2            0          8        0     6                1   
6346          3            3          0        0     4                1   
376           5            0          0        0     6                1   
7403          4            2          7        0     3                1   
873           2            0          0        1     6                1   
6459          3            3          7        0     8                1   
6266          3            2          0        0     8                1   
4911          3            3          7        1     6                1   
2284          2            2          0        1     6                1   
5292          2            2          7        0     3                1   
5544          4            2          7        1     6                1   
5486          2            2          3        0     4                1   
2148          3            0          7        1     6                1   
607           3            2          0        1     0                1   
...         ...          ...        ...      ...   ...              ...   
6216          2            2          7        0     4                1   
2893          2            2          7        1     6                1   
537           5            0          0        0     6                1   
1701          3            3          8        0     6                1   
2897          3            0          0        1     6                1   
7768          4            2          7        0     8                1   
2222          2            2          7        1     6                1   
2135          2            2          3        1     6                1   
2599          2            2          3        1     6                1   
7654          4            3          0        0     4                1   
705           3            2          9        1     1                1   
6458          4            2          0        0     3                1   
3468          2            0          3        0     2                1   
6744          2            0          3        0     6                1   
7640          0            3          8        0     6                1   
7238          4            2          0        0     3                1   
6743          3            3          7        0     3                1   
5924          3            2          9        0     4                1   
5874          2            2          5        1     6                1   
4373          3            0          3        0     4                1   
7891          4            2          0        0     8                1   
1033          3            0          0        0     6                1   
7527          4            2          0        0     8                1   
5827          3            3          3        1     4                1   
4859          3            2          0        1     6                1   
4931          2            2          7        1     6                1   
3264          2            0          3        0     4                1   
1653          2            3          3        0     6                1   
2607          3            0          0        1     6                1   
2732          2            2          3        1     6                1   

      gill-spacing  gill-size  gill-color  stalk-shape   ...     \
5314             0          0           3            1   ...      
2075             0          0           0            0   ...      
5165             0          0           7            1   ...      
1155             0          0           0            0   ...      
4448             0          0           3            0   ...      
1045             0          0          10            0   ...      
3181             0          1           8            0   ...      
3225             0          0           8            1   ...      
1083             1          0           1            1   ...      
6239             0          1           2            1   ...      
4700             0          0           3            0   ...      
2769             0          0           8            1   ...      
5020             0          0           3            1   ...      
1302             1          0           3            1   ...      
2604             0          0           1            1   ...      
4864             0          0           3            0   ...      
2058             1          0           7            1   ...      
6346             0          1           2            1   ...      
376              0          1           0            0   ...      
7403             0          1           2            1   ...      
873              0          0           1            1   ...      
6459             0          1           2            1   ...      
6266             0          1           2            1   ...      
4911             0          0          10            0   ...      
2284             0          0           7            1   ...      
5292             0          1           2            1   ...      
5544             0          0          10            0   ...      
5486             0          0           7            0   ...      
2148             0          0           8            1   ...      
607              0          0           1            0   ...      
...            ...        ...         ...          ...   ...      
6216             0          1           2            1   ...      
2893             0          0           7            1   ...      
537              0          1           7            0   ...      
1701             1          0           0            1   ...      
2897             0          0           8            1   ...      
7768             0          1           2            1   ...      
2222             0          0           1            1   ...      
2135             0          0           8            1   ...      
2599             0          0          10            1   ...      
7654             0          1           2            1   ...      
705              0          0           7            0   ...      
6458             0          1           2            1   ...      
3468             1          1           7            0   ...      
6744             1          0           4            0   ...      
7640             1          0           7            0   ...      
7238             0          1           2            1   ...      
6743             0          1           2            1   ...      
5924             0          0           7            0   ...      
5874             0          0          10            0   ...      
4373             0          0           7            0   ...      
7891             0          1           2            1   ...      
1033             1          0           7            1   ...      
7527             0          1           2            1   ...      
5827             0          0           7            1   ...      
4859             0          0           9            0   ...      
4931             0          0           9            0   ...      
3264             0          0           3            0   ...      
1653             1          0           3            1   ...      
2607             0          0           1            1   ...      
2732             0          0          10            1   ...      

      stalk-surface-below-ring  stalk-color-above-ring  \
5314                         3                       7   
2075                         3                       7   
5165                         3                       7   
1155                         3                       7   
4448                         2                       1   
1045                         3                       7   
3181                         3                       7   
3225                         3                       3   
1083                         0                       7   
6239                         2                       7   
4700                         2                       0   
2769                         3                       7   
5020                         0                       7   
1302                         0                       7   
2604                         3                       3   
4864                         2                       5   
2058                         0                       7   
6346                         3                       5   
376                          3                       7   
7403                         2                       5   
873                          3                       3   
6459                         3                       7   
6266                         3                       5   
4911                         3                       7   
2284                         3                       7   
5292                         2                       7   
5544                         3                       7   
5486                         2                       5   
2148                         3                       7   
607                          1                       7   
...                        ...                     ...   
6216                         3                       5   
2893                         3                       3   
537                          3                       7   
1701                         3                       7   
2897                         3                       3   
7768                         2                       7   
2222                         3                       7   
2135                         3                       5   
2599                         3                       3   
7654                         3                       7   
705                          1                       7   
6458                         2                       5   
3468                         3                       7   
6744                         2                       7   
7640                         3                       7   
7238                         2                       5   
6743                         3                       5   
5924                         2                       0   
5874                         3                       6   
4373                         2                       1   
7891                         3                       7   
1033                         0                       7   
7527                         3                       5   
5827                         0                       7   
4859                         3                       6   
4931                         3                       6   
3264                         2                       5   
1653                         3                       7   
2607                         3                       3   
2732                         3                       3   

      stalk-color-below-ring  veil-type  veil-color  ring-number  ring-type  \
5314                       7          0           2            1          4   
2075                       7          0           2            1          4   
5165                       7          0           2            1          4   
1155                       7          0           2            1          4   
4448                       1          0           2            1          2   
1045                       7          0           2            1          4   
3181                       7          0           2            1          4   
3225                       5          0           2            1          4   
1083                       7          0           2            1          0   
6239                       5          0           2            1          0   
4700                       0          0           2            1          2   
2769                       3          0           2            1          4   
5020                       7          0           2            1          4   
1302                       7          0           2            1          0   
2604                       7          0           2            1          4   
4864                       5          0           2            1          2   
2058                       7          0           2            1          0   
6346                       5          0           2            1          0   
376                        7          0           2            1          4   
7403                       5          0           2            1          0   
873                        7          0           2            1          4   
6459                       5          0           2            1          0   
6266                       5          0           2            1          0   
4911                       6          0           2            2          0   
2284                       5          0           2            1          4   
5292                       5          0           2            1          0   
5544                       7          0           2            2          0   
5486                       5          0           2            1          2   
2148                       7          0           2            1          4   
607                        7          0           2            1          4   
...                      ...        ...         ...          ...        ...   
6216                       7          0           2            1          0   
2893                       5          0           2            1          4   
537                        7          0           2            1          4   
1701                       7          0           2            1          0   
2897                       3          0           2            1          4   
7768                       5          0           2            1          0   
2222                       7          0           2            1          4   
2135                       7          0           2            1          4   
2599                       7          0           2            1          4   
7654                       7          0           2            1          0   
705                        7          0           2            1          4   
6458                       5          0           2            1          0   
3468                       7          0           2            1          4   
6744                       7          0           2            2          4   
7640                       7          0           2            2          4   
7238                       7          0           2            1          0   
6743                       5          0           2            1          0   
5924                       5          0           2            1          2   
5874                       7          0           2            2          0   
4373                       5          0           2            1          2   
7891                       7          0           2            1          0   
1033                       7          0           2            1          0   
7527                       7          0           2            1          0   
5827                       7          0           2            1          4   
4859                       7          0           2            2          0   
4931                       6          0           2            2          0   
3264                       0          0           2            1          2   
1653                       7          0           2            1          0   
2607                       3          0           2            1          4   
2732                       5          0           2            1          4   

      spore-print-color  population  habitat  
5314                  3           4        0  
2075                  0           2        2  
5165                  3           3        0  
1155                  1           3        2  
4448                  3           5        0  
1045                  1           3        0  
3181                  0           4        6  
3225                  1           5        6  
1083                  0           3        0  
6239                  7           4        6  
4700                  3           4        3  
2769                  1           5        6  
5020                  3           4        4  
1302                  1           3        0  
2604                  1           4        6  
4864                  3           5        0  
2058                  1           0        0  
6346                  7           4        1  
376                   0           5        4  
7403                  7           4        1  
873                   0           4        6  
6459                  7           4        6  
6266                  7           4        3  
4911                  7           1        5  
2284                  0           5        6  
5292                  7           4        6  
5544                  7           1        5  
5486                  3           5        3  
2148                  1           5        6  
607                   0           5        0  
...                 ...         ...      ...  
6216                  7           4        1  
2893                  0           4        6  
537                   0           4        4  
1701                  1           3        0  
2897                  0           4        6  
7768                  7           4        3  
2222                  1           4        6  
2135                  1           5        6  
2599                  0           4        6  
7654                  7           4        3  
705                   0           5        3  
6458                  7           4        1  
3468                  1           4        6  
6744                  7           3        0  
7640                  7           3        0  
7238                  7           4        3  
6743                  7           4        6  
5924                  3           5        6  
5874                  7           1        5  
4373                  3           5        0  
7891                  7           4        3  
1033                  1           3        0  
7527                  7           4        6  
5827                  3           4        0  
4859                  7           1        5  
4931                  7           1        5  
3264                  3           5        3  
1653                  1           3        0  
2607                  1           4        6  
2732                  1           5        6  

[5686 rows x 22 columns] 5314    1
2075    0
5165    1
1155    0
4448    1
1045    0
3181    1
3225    0
1083    0
6239    1
4700    1
2769    0
5020    1
1302    0
2604    0
4864    1
2058    0
6346    1
376     0
7403    1
873     0
6459    1
6266    1
4911    0
2284    0
5292    1
5544    0
5486    1
2148    0
607     0
       ..
6216    1
2893    0
537     0
1701    0
2897    0
7768    1
2222    0
2135    0
2599    0
7654    1
705     0
6458    1
3468    1
6744    0
7640    0
7238    1
6743    1
5924    1
5874    0
4373    1
7891    1
1033    0
7527    1
5827    1
4859    0
4931    0
3264    1
1653    0
2607    0
2732    0
Name: class, Length: 5686, dtype: int64
      cap-shape  cap-surface  cap-color  bruises  odor  gill-attachment  \
380           2            2          0        1     7                1   
3641          3            2          3        1     6                1   
273           2            2          9        1     0                1   
1029          2            3          8        0     6                1   
684           2            0          0        1     6                1   
2899          3            2          0        1     6                1   
1568          3            3          0        1     7                1   
6126          3            3          7        0     8                1   
2267          2            2          0        1     6                1   
4030          2            2          9        0     4                1   
5481          4            3          5        1     6                1   
5010          2            2          7        1     6                1   
1140          3            0          8        0     6                1   
49            3            2          9        1     1                1   
888           2            2          9        1     0                1   
4816          3            0          9        0     4                1   
2676          2            0          3        1     6                1   
1916          3            2          8        1     7                1   
1454          2            3          3        0     6                1   
2030          2            2          7        1     6                1   
3443          2            0          5        0     2                1   
3608          3            0          3        0     4                1   
5870          3            2          9        0     4                1   
7145          2            2          7        0     4                1   
4978          2            2          9        0     4                1   
4136          2            0          3        0     4                1   
1103          2            2          0        1     7                1   
7946          2            2          2        1     6                1   
2164          3            0          0        1     6                1   
5129          2            3          1        1     4                1   
...         ...          ...        ...      ...   ...              ...   
5790          2            2          0        0     8                1   
7608          4            2          0        0     3                1   
238           2            2          9        1     1                1   
1524          2            3          0        0     6                1   
4788          3            2          0        1     6                1   
2165          2            0          7        1     6                1   
4218          3            0          9        0     4                1   
4285          2            0          9        0     4                1   
1828          2            3          3        0     6                1   
2643          3            2          0        1     6                1   
7652          3            3          0        0     6                0   
7625          3            2          0        0     4                1   
6925          3            2          0        0     8                1   
17            2            3          0        1     7                1   
7494          3            2          7        0     8                1   
5560          2            3          8        1     4                1   
3432          2            0          3        0     4                1   
5281          3            2          8        1     6                1   
2872          2            2          0        1     6                1   
2368          2            2          0        1     6                1   
965           3            3          3        0     6                1   
172           2            0          9        1     1                1   
1428          3            2          0        1     1                1   
483           3            0          3        0     6                1   
5221          2            2          5        1     6                1   
520           2            3          8        1     1                1   
36            5            0          3        0     6                1   
7959          4            2          7        0     4                1   
6520          2            2          7        0     3                1   
6005          3            2          7        0     8                1   

      gill-spacing  gill-size  gill-color  stalk-shape   ...     \
380              0          1           7            0   ...      
3641             0          0           7            1   ...      
273              0          0           0            0   ...      
1029             1          0           0            1   ...      
684              0          0           7            1   ...      
2899             0          0           1            1   ...      
1568             0          1           0            0   ...      
6126             0          1           2            1   ...      
2267             0          0           7            1   ...      
4030             0          0           7            0   ...      
5481             0          0           9            0   ...      
5010             0          0          10            0   ...      
1140             1          0           1            1   ...      
49               0          0          10            0   ...      
888              0          0          10            0   ...      
4816             0          0           3            0   ...      
2676             0          0           1            1   ...      
1916             0          1          10            0   ...      
1454             1          0           1            1   ...      
2030             0          0           8            1   ...      
3443             1          1           7            0   ...      
3608             0          0           7            0   ...      
5870             0          0           3            0   ...      
7145             0          1           2            1   ...      
4978             0          0           7            0   ...      
4136             0          0           3            0   ...      
1103             0          1          10            0   ...      
7946             0          0          10            0   ...      
2164             0          0           8            1   ...      
5129             0          0           7            1   ...      
...            ...        ...         ...          ...   ...      
5790             0          1           2            1   ...      
7608             0          1           2            1   ...      
238              0          0           1            0   ...      
1524             1          0           1            1   ...      
4788             0          0           1            1   ...      
2165             0          0           1            1   ...      
4218             0          0           7            0   ...      
4285             0          0           4            0   ...      
1828             1          0           7            1   ...      
2643             0          0           8            1   ...      
7652             0          0           1            0   ...      
7625             0          1           2            1   ...      
6925             0          1           2            1   ...      
17               0          1           1            0   ...      
7494             0          1           2            1   ...      
5560             0          0           7            1   ...      
3432             0          0           4            0   ...      
5281             1          1          10            0   ...      
2872             0          0           8            1   ...      
2368             0          0           1            1   ...      
965              1          0           1            1   ...      
172              1          1           1            1   ...      
1428             0          0           1            0   ...      
483              0          1           4            0   ...      
5221             0          0          10            0   ...      
520              0          0          10            0   ...      
36               0          1           0            0   ...      
7959             0          1           2            1   ...      
6520             0          1           2            1   ...      
6005             0          1           2            1   ...      

      stalk-surface-below-ring  stalk-color-above-ring  \
380                          3                       7   
3641                         3                       3   
273                          3                       7   
1029                         3                       7   
684                          3                       5   
2899                         3                       3   
1568                         3                       7   
6126                         3                       7   
2267                         3                       3   
4030                         2                       5   
5481                         3                       7   
5010                         3                       6   
1140                         3                       7   
49                           1                       7   
888                          1                       7   
4816                         2                       0   
2676                         3                       7   
1916                         3                       7   
1454                         0                       7   
2030                         3                       7   
3443                         3                       7   
3608                         2                       1   
5870                         2                       1   
7145                         2                       7   
4978                         2                       5   
4136                         2                       1   
1103                         3                       7   
7946                         3                       7   
2164                         3                       7   
5129                         3                       7   
...                        ...                     ...   
5790                         2                       5   
7608                         3                       7   
238                          1                       7   
1524                         0                       7   
4788                         3                       5   
2165                         3                       7   
4218                         2                       5   
4285                         2                       1   
1828                         3                       7   
2643                         3                       3   
7652                         3                       4   
7625                         2                       5   
6925                         2                       7   
17                           3                       7   
7494                         2                       5   
5560                         3                       7   
3432                         2                       0   
5281                         3                       7   
2872                         3                       5   
2368                         3                       3   
965                          3                       7   
172                          3                       7   
1428                         1                       7   
483                          3                       7   
5221                         3                       6   
520                          3                       7   
36                           3                       7   
7959                         3                       7   
6520                         3                       7   
6005                         2                       5   

      stalk-color-below-ring  veil-type  veil-color  ring-number  ring-type  \
380                        7          0           2            1          4   
3641                       3          0           2            1          4   
273                        7          0           2            1          4   
1029                       7          0           2            1          0   
684                        7          0           2            1          4   
2899                       5          0           2            1          4   
1568                       7          0           2            1          4   
6126                       7          0           2            1          0   
2267                       3          0           2            1          4   
4030                       5          0           2            1          2   
5481                       7          0           2            2          0   
5010                       7          0           2            2          0   
1140                       7          0           2            1          0   
49                         7          0           2            1          4   
888                        7          0           2            1          4   
4816                       1          0           2            1          2   
2676                       5          0           2            1          4   
1916                       7          0           2            1          4   
1454                       7          0           2            1          0   
2030                       5          0           2            1          4   
3443                       7          0           2            1          4   
3608                       1          0           2            1          2   
5870                       1          0           2            1          2   
7145                       7          0           2            1          0   
4978                       1          0           2            1          2   
4136                       1          0           2            1          2   
1103                       7          0           2            1          4   
7946                       7          0           2            2          4   
2164                       5          0           2            1          4   
5129                       7          0           2            1          4   
...                      ...        ...         ...          ...        ...   
5790                       5          0           2            1          0   
7608                       5          0           2            1          0   
238                        7          0           2            1          4   
1524                       7          0           2            1          0   
4788                       7          0           2            1          4   
2165                       5          0           2            1          4   
4218                       1          0           2            1          2   
4285                       1          0           2            1          2   
1828                       7          0           2            1          0   
2643                       3          0           2            1          4   
7652                       4          0           0            1          4   
7625                       5          0           2            1          0   
6925                       7          0           2            1          0   
17                         7          0           2            1          4   
7494                       7          0           2            1          0   
5560                       7          0           2            1          4   
3432                       0          0           2            1          2   
5281                       7          0           2            1          4   
2872                       7          0           2            1          4   
2368                       7          0           2            1          4   
965                        7          0           2            1          0   
172                        7          0           2            1          4   
1428                       7          0           2            1          4   
483                        7          0           2            1          4   
5221                       6          0           2            2          0   
520                        7          0           2            1          4   
36                         7          0           2            1          4   
7959                       5          0           2            1          0   
6520                       7          0           2            1          0   
6005                       5          0           2            1          0   

      spore-print-color  population  habitat  
380                   0           3        4  
3641                  0           5        6  
273                   1           2        2  
1029                  0           0        0  
684                   1           4        6  
2899                  0           4        6  
1568                  0           4        4  
6126                  7           4        1  
2267                  1           4        6  
4030                  3           5        6  
5481                  7           1        5  
5010                  7           1        5  
1140                  1           0        0  
49                    0           3        3  
888                   0           5        3  
4816                  3           4        3  
2676                  0           4        6  
1916                  0           4        4  
1454                  0           0        0  
2030                  0           4        6  
3443                  1           4        6  
3608                  3           5        3  
5870                  3           5        0  
7145                  7           4        1  
4978                  3           4        6  
4136                  3           5        6  
1103                  1           3        0  
7946                  7           4        3  
2164                  1           5        6  
5129                  3           4        0  
...                 ...         ...      ...  
5790                  7           4        1  
7608                  7           4        1  
238                   0           3        0  
1524                  1           0        0  
4788                  1           4        6  
2165                  1           5        6  
4218                  3           5        0  
4285                  3           5        6  
1828                  1           0        0  
2643                  0           4        6  
7652                  2           1        1  
7625                  7           4        6  
6925                  7           4        6  
17                    0           3        0  
7494                  7           4        1  
5560                  3           4        0  
3432                  3           4        3  
5281                  7           1        1  
2872                  1           5        6  
2368                  0           4        6  
965                   0           3        0  
172                   6           4        6  
1428                  0           3        3  
483                   0           5        4  
5221                  7           1        5  
520                   0           2        2  
36                    0           4        4  
7959                  7           4        1  
6520                  7           4        3  
6005                  7           4        6  

[2438 rows x 22 columns] 380     1
3641    0
273     0
1029    0
684     0
2899    0
1568    1
6126    1
2267    0
4030    1
5481    0
5010    0
1140    0
49      0
888     0
4816    1
2676    0
1916    1
1454    0
2030    0
3443    1
3608    1
5870    1
7145    1
4978    1
4136    1
1103    1
7946    0
2164    0
5129    1
       ..
5790    1
7608    1
238     0
1524    0
4788    0
2165    0
4218    1
4285    1
1828    0
2643    0
7652    0
7625    1
6925    1
17      1
7494    1
5560    1
3432    1
5281    1
2872    0
2368    0
965     0
172     0
1428    0
483     0
5221    0
520     0
36      0
7959    1
6520    1
6005    1
Name: class, Length: 2438, dtype: int64
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 吃肉的小馒头 2021-05-20 14:54
    已采纳

    pd.set_option("max_columns", 5)

    设置显示最大列数就行

    已采纳该答案
    1 打赏 评论
  • 有问必答小助手 2021-05-20 19:04

    您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    打赏 评论

相关推荐 更多相似问题