簡單的紀錄一下pandas觀看數據以及load數據的方法
1 | #data source:http://archive.ics.uci.edu/ml/datasets/Iris |
1 | #資料前部分(可以指定顯示行數,預設5) |
sepal_length_in_cm | sepal_width_in_cm | petal_length_in_cm | petal_width_in_cm | class | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa |
1 | #資料後部分(可以指定顯示行數,預設5) |
sepal_length_in_cm | sepal_width_in_cm | petal_length_in_cm | petal_width_in_cm | class | |
---|---|---|---|---|---|
147 | 6.5 | 3.0 | 5.2 | 2.0 | Iris-virginica |
148 | 6.2 | 3.4 | 5.4 | 2.3 | Iris-virginica |
149 | 5.9 | 3.0 | 5.1 | 1.8 | Iris-virginica |
1 | #資料摘要 |
sepal_length_in_cm | sepal_width_in_cm | petal_length_in_cm | petal_width_in_cm | |
---|---|---|---|---|
count | 150.000000 | 150.000000 | 150.000000 | 150.000000 |
mean | 5.843333 | 3.054000 | 3.758667 | 1.198667 |
std | 0.828066 | 0.433594 | 1.764420 | 0.763161 |
min | 4.300000 | 2.000000 | 1.000000 | 0.100000 |
25% | 5.100000 | 2.800000 | 1.600000 | 0.300000 |
50% | 5.800000 | 3.000000 | 4.350000 | 1.300000 |
75% | 6.400000 | 3.300000 | 5.100000 | 1.800000 |
max | 7.900000 | 4.400000 | 6.900000 | 2.500000 |
1 | #選取特定列 |
0 5.1
1 4.9
2 4.7
3 4.6
4 5.0
Name: sepal_length_in_cm, dtype: float64
1 | #選取特定多個列 |
sepal_length_in_cm | class | |
---|---|---|
0 | 5.1 | Iris-setosa |
1 | 4.9 | Iris-setosa |
2 | 4.7 | Iris-setosa |
3 | 4.6 | Iris-setosa |
4 | 5.0 | Iris-setosa |
1 | #在讀取的時候如果數據集太大的讀取 |
sepal_length_in_cm sepal_width_in_cm petal_length_in_cm \
0 5.1 3.5 1.4
1 4.9 3.0 1.4
2 4.7 3.2 1.3
3 4.6 3.1 1.5
4 5.0 3.6 1.4
5 5.4 3.9 1.7
6 4.6 3.4 1.4
7 5.0 3.4 1.5
8 4.4 2.9 1.4
9 4.9 3.1 1.5
petal_width_in_cm class
0 0.2 Iris-setosa
1 0.2 Iris-setosa
2 0.2 Iris-setosa
3 0.2 Iris-setosa
4 0.2 Iris-setosa
5 0.4 Iris-setosa
6 0.3 Iris-setosa
7 0.2 Iris-setosa
8 0.2 Iris-setosa
9 0.1 Iris-setosa
1 | #當真的在使用chunk讀取非常大的數據集時 |
sepal_length_in_cm | sepal_width_in_cm | petal_length_in_cm | petal_width_in_cm | class | |
---|---|---|---|---|---|
0 | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa |
1 | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa |
2 | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa |
3 | 4.6 | 3.1 | 1.5 | 0.2 | Iris-setosa |
4 | 5.0 | 3.6 | 1.4 | 0.2 | Iris-setosa |
5 | 5.4 | 3.9 | 1.7 | 0.4 | Iris-setosa |
6 | 4.6 | 3.4 | 1.4 | 0.3 | Iris-setosa |
7 | 5.0 | 3.4 | 1.5 | 0.2 | Iris-setosa |
8 | 4.4 | 2.9 | 1.4 | 0.2 | Iris-setosa |
9 | 4.9 | 3.1 | 1.5 | 0.1 | Iris-setosa |