回答編集履歴

1

コード追加

2017/11/12 14:01

投稿

wakame
wakame

スコア1170

test CHANGED
@@ -1 +1,57 @@
1
+ ```python
2
+
3
+ import pandas as pd
4
+
5
+ from pprint import pprint
6
+
7
+
8
+
9
+ df = pd.read_csv("adult.data", header=None, delimiter=r"\s+", )
10
+
11
+ df.columns = ['age', 'workclass', 'fnlwgt', 'education', 'education-num',
12
+
13
+ 'marital-status', 'occupation', 'relationship', 'race',
14
+
15
+ 'sex', 'capital-gain', 'capital-loss', 'hours-per-week',
16
+
17
+ 'native-country', 'income_class']
18
+
19
+
20
+
21
+ df["income_class"] = df["income_class"].map({"<=50K": 0, ">50K": 1})
22
+
23
+ pprint(df["income_class"].head(10))
24
+
25
+ """
26
+
27
+ 0 0
28
+
29
+ 1 0
30
+
31
+ 2 0
32
+
33
+ 3 0
34
+
35
+ 4 0
36
+
37
+ 5 0
38
+
39
+ 6 0
40
+
41
+ 7 1
42
+
43
+ 8 1
44
+
45
+ 9 1
46
+
47
+ Name: income_class, dtype: int64
48
+
49
+
50
+
51
+ """
52
+
53
+ ```
54
+
55
+
56
+
1
57
  [Analysis of the Adult data set from UCI Machine Learning Repository](http://blog.pangyanhan.com/posts/2017-02-15-analysis-of-the-adult-data-set-from-uci-machine-learning-repository.ipynb.html)