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

回答編集履歴

2

コード修正

2022/01/10 05:59

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  > x軸に点数、y軸に点数毎の人数を表示させたいと考えています。
2
2
 
3
3
  barではなくhistで描画すべきかと思います。
4
-
4
+ また、値が`6/14実施`の行にひきづられて文字列と判定されているようなので`int`に変換します。
5
5
  ```Python
6
6
  import pandas as pd
7
7
  import matplotlib.pyplot as plt
@@ -47,12 +47,10 @@
47
47
  df = pd.read_csv(StringIO(s))
48
48
  a = df['第1回']
49
49
  b = a.drop(0)
50
- x = b
50
+ x = b.astype(int)
51
51
 
52
- print(x)
53
-
54
52
  #height = range(0,34)
55
53
  plt.hist(x) # 変更
56
54
  plt.show()
57
55
  ```
58
- ![イメージ説明](7234a998c0101535aec2f535af88d2ed.png)
56
+ ![イメージ説明](6522f71a44183bbbd5f1829ffdf1be9a.png)

1

コード修正

2022/01/10 05:59

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -1,5 +1,7 @@
1
- `第1回`列が`6/14実施`行のせいで文字列認識されてるように思えます。
1
+ > x軸に点数、y軸に点数毎人数を表示さいと考えています。
2
+
2
- 以下のようにintに変換るとよいかと思います。
3
+ barではなくhistで描画べきかと思います。
4
+
3
5
  ```Python
4
6
  import pandas as pd
5
7
  import matplotlib.pyplot as plt
@@ -45,10 +47,12 @@
45
47
  df = pd.read_csv(StringIO(s))
46
48
  a = df['第1回']
47
49
  b = a.drop(0)
48
- x = b.astype(int) # 追加
50
+ x = b
49
51
 
52
+ print(x)
53
+
50
- height = range(0,34)
54
+ #height = range(0,34)
51
- plt.bar(x, height)
55
+ plt.hist(x) # 変更
52
56
  plt.show()
53
57
  ```
54
- ![イメージ説明](4d2c14fdc2d1bbcece79ccd9dcb28b00.png)
58
+ ![イメージ説明](7234a998c0101535aec2f535af88d2ed.png)