回答編集履歴
1
d
test
CHANGED
@@ -17,3 +17,31 @@
|
|
17
17
|
print(df.size) # データ数
|
18
18
|
|
19
19
|
```
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
それとも重複なしのデータの種類の数のことでしょうか
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
```python
|
28
|
+
|
29
|
+
import pandas as pd
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
df = pd.DataFrame({'class':['a','a','a','b','b','c'], 'score':[0,20,10,1,3,21]})
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
print(df["class"].value_counts())
|
38
|
+
|
39
|
+
# a 3
|
40
|
+
|
41
|
+
# b 2
|
42
|
+
|
43
|
+
# c 1
|
44
|
+
|
45
|
+
# Name: class, dtype: int64
|
46
|
+
|
47
|
+
```
|