0

以下のようなワークシートで作業しています。

日時バッジ名
2013/10/31    
8:01:02 AM 131078 YEO、ニタ
8:03:17 AM 415416 PEH、魏
2013/10/30    
8:11:02 AM 131098 リー、アリス
8:53:17 AM 215416 EG、市
...
  1. 1日で重複なく入場した人数を数えたい。正確な時間ではなく、日付だけです。各人には固有のバッジ番号があります。

  2. その後、すべての従業員のバッジ番号が記載された別のワークシートがあります。入力された人をこのシートと比較して、訪問者を除外したい、つまり、両方のシート内の人が残ります。次に、いくつあるか数えます。

要約すると、1 か月で、毎日入室した従業員の数を数えますが、訪問者は数えません。日付に対して数値をプロットします。

これは、Excel、ピボット テーブル、または VBA を使用してどのように行うことができますか?

4

2 に答える 2

1

Excel で、左端に列を追加し、「日付/時刻」が B1 にあると仮定して、A2 に入力し、それ=IF(ISBLANK(C2),B2,A1)に合わせて下にコピーします。ColumnA をコピーし、特殊な値を上に貼り付けます。(空白) の ColumnC をフィルター処理し、選択した行を削除します。DateA1を追加します。@Brettが推奨するように、データレイアウトは多かれ少なかれあるはずです。


ルックアップ関数を使用して、各行に訪問者かどうかの表示を追加します。

画像の左側にあるように、ソース データから示されているように作成されたピボットテーブルには、1 日ごとの一意のバッジ アクセス数が表示されます。

SO19764305 の例

n[レポート フィルター] フィールドで のみ選択するようにフィルター処理すると、従業員のみに相当するものがあります。

月ごとの数値については、[グループ] (クイック メニュー)、[別]、[月] 機能を使用します。

グラフ化するには、行ラベルからバッジを削除し、適切なグラフを挿入します。

于 2013-12-13T03:57:22.923 に答える
1

このようなもの

from collections import defaultdict

# collect all visitors in a dictionary where the key is the date, and
# the value is a set of badge numbers
visitorsPerDay = defaultdict(set)

# store the last read date value
currentDate = None

with open('filename') as f:
    for line in f:
        # if the line is 10 characters long, it’s a date line
        if len(line.strip()) == 10:
            # store the date value
            currentDate = line.strip()
        elif currentDate:
            # extract the badge number; if the file is tab
            # separated, even better: split by \t
            time, badge, _ = (part.strip() for part in line.split('   ', 2))

            # add the badge number to the set within the dictionary
            visitorsPerDay[currentDate].add(badge)

# now for every date, count the number of (unique) visitors
for date, visitors in visitorsPerDay.items():
    print(date, len(visitors))
于 2013-12-13T03:00:53.187 に答える