質問するログイン新規登録

回答編集履歴

2

edit

2018/07/24 03:59

投稿

mkgrei
mkgrei

スコア8562

answer CHANGED
@@ -3,7 +3,7 @@
3
3
  https://stackoverflow.com/questions/28651079/pandas-unstack-problems-valueerror-index-contains-duplicate-entries-cannot-re
4
4
 
5
5
  重複するものが一箇所に固まっていないので。
6
- しておけばよいのでは?
6
+ しておけばよいのでは?
7
7
  以下の二つを比べてみてください。
8
8
 
9
9
  ```python

1

edit

2018/07/24 03:59

投稿

mkgrei
mkgrei

スコア8562

answer CHANGED
@@ -1,3 +1,25 @@
1
1
  titleに重複する項目があるからでは?
2
2
 
3
- https://stackoverflow.com/questions/28651079/pandas-unstack-problems-valueerror-index-contains-duplicate-entries-cannot-re
3
+ https://stackoverflow.com/questions/28651079/pandas-unstack-problems-valueerror-index-contains-duplicate-entries-cannot-re
4
+
5
+ 重複するものが一箇所に固まっていないので。
6
+ そーとしておけばよいのでは?
7
+ 以下の二つを比べてみてください。
8
+
9
+ ```python
10
+ import pandas as pd
11
+ df = pd.DataFrame({'foo': ['one','two','one','two','two','two'],
12
+ 'bar': ['A', 'B', 'C', 'A', 'B', 'C'],
13
+ 'baz': [1, 2, 3, 4, 5, 6]})
14
+ print(df)
15
+ df.pivot(index='foo', columns='bar', values='baz')
16
+ ```
17
+
18
+ ```python
19
+ import pandas as pd
20
+ df = pd.DataFrame({'foo': ['one','one','one','two','two','two'],
21
+ 'bar': ['A', 'B', 'C', 'A', 'B', 'C'],
22
+ 'baz': [1, 2, 3, 4, 5, 6]})
23
+ print(df)
24
+ df.pivot(index='foo', columns='bar', values='baz')
25
+ ```