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

質問編集履歴

3

修正

2019/11/29 08:54

投稿

john_doe_
john_doe_

スコア354

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,11 @@
1
1
  列・行を転置させて、列名をカラムとして利用したいと考えています。
2
2
 
3
+ 完成イメージ
4
+ |名前|性別|年齢|
5
+ |:--|:--:|--:|
6
+ |日本 花子|女性|28歳|
7
+
8
+
3
9
  下記のデータが格納されたcsvファイルをpandasで読み込み、
4
10
  df = pd.read_csv('hoge.csv')
5
11
  ![イメージ説明](f305c53669885c52f055145cadc6a410.png)

2

修正

2019/11/29 08:54

投稿

john_doe_
john_doe_

スコア354

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,7 @@
12
12
  pandasのピボットテーブル関数を試してみる
13
13
 
14
14
  ```ここに言語を入力
15
- pd.pivot_table(df, index='', columns=['項目名'])
15
+ pd.pivot_table(df, index='検索条件', columns=['項目名'])
16
16
 
17
17
  DataError: No numeric types to aggregate
18
18
  ```

1

追記

2019/11/29 08:52

投稿

john_doe_
john_doe_

スコア354

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