回答編集履歴

2

2023/01/25 00:31

投稿

melian
melian

スコア19825

test CHANGED
@@ -3,10 +3,10 @@
3
3
  import pandas as pd
4
4
 
5
5
  df = pd.DataFrame({'place': ['京都', '千葉', '千葉', '東京', '東京', '東京']})
6
- dfx = df.value_counts('place').to_frame('place')
6
+ dfx = df.value_counts('place').to_frame('count')
7
7
  print(dfx)
8
8
 
9
- # place
9
+ # count
10
10
  # place
11
11
  # 東京 3
12
12
  # 千葉 2

1

2023/01/25 00:25

投稿

melian
melian

スコア19825

test CHANGED
@@ -1,3 +1,4 @@
1
+ `pandas.DataFrame.value_counts()` を使う場合。
1
2
  ```python
2
3
  import pandas as pd
3
4