重複データのカウント

下記の設問に対する答えとして相応しものを選択肢から選び、次のコードの空欄(##########)を埋めてください.

変数 df の “col2” 列には、何パターンの要素があるか調べてください.
(要素のパターン = 重複を除いた行数の意)

import pandas as pd

df = pd.DataFrame({“col1” : [0, 9, 3, 3, 6, 1, 2, 2, 8],
“col2” : [“a”, “c”, “d”, “b”, “c”, “c”, “a”, “a”, “e”]})

print(##########)

[選択肢]
1. pd.value_counts(set(df.col2.unique()))
2. set(df.col2.unique()).counts()
3. set(df.col2.unique())
4. set(df.col2.unique).shpae[0]

Leave a comment

Your email address will not be published. Required fields are marked *