質問編集履歴

3

修正

2019/11/29 08:54

投稿

john_doe_
john_doe_

スコア354

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,16 @@
1
1
  列・行を転置させて、列名をカラムとして利用したいと考えています。
2
+
3
+
4
+
5
+ 完成イメージ
6
+
7
+ |名前|性別|年齢|
8
+
9
+ |:--|:--:|--:|
10
+
11
+ |日本 花子|女性|28歳|
12
+
13
+
2
14
 
3
15
 
4
16
 

2

修正

2019/11/29 08:54

投稿

john_doe_
john_doe_

スコア354

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  ```ここに言語を入力
28
28
 
29
- pd.pivot_table(df, index='', columns=['項目名'])
29
+ pd.pivot_table(df, index='検索条件', columns=['項目名'])
30
30
 
31
31
 
32
32
 

1

追記

2019/11/29 08:52

投稿

john_doe_
john_doe_

スコア354

test CHANGED
File without changes
test CHANGED
@@ -1,19 +1,41 @@
1
- 下記のデータが格納csvファイルをpandasで読み込み、
1
+ 列・行を転置せて、列名をカラムとして利用しいと考えています。
2
2
 
3
3
 
4
4
 
5
+ 下記のデータが格納されたcsvファイルをpandasで読み込み、
6
+
5
7
  df = pd.read_csv('hoge.csv')
6
8
 
7
- ![イメージ説明](c3f101914f52eaa78d4c6385ca523aa8.png)
9
+ ![イメージ説明](f305c53669885c52f055145cadc6a410.png)
8
10
 
9
11
 
10
12
 
11
13
 
12
14
 
15
+
16
+
13
- 列・行を転置させて、列名をカラムとし利用たいと考えてい
17
+ df.T、で転置させるとカラム名がなくなってしま
18
+
19
+ ![イメージ説明](100ed3d25888b4250dfa3217b00759df.png)
14
20
 
15
21
 
16
22
 
17
- df.T
23
+ pandasのピボットテーブル関数を試してみる
18
24
 
25
+
26
+
27
+ ```ここに言語を入力
28
+
29
+ pd.pivot_table(df, index='', columns=['項目名'])
30
+
31
+
32
+
19
- ![イメージ説明](a0294c7123d97cb1ac012b4948f00f1e.png)
33
+ DataError: No numeric types to aggregate
34
+
35
+ ```
36
+
37
+
38
+
39
+ 稚拙な質問かとは存じますが、ご教示いただけましたら幸甚です。
40
+
41
+ 何卒よろしくお願い申し上げます。