Efficient way to create matrix that shows if data exits per day
You should be able to just use a pandas pivot table for this purpose:
import pandas as pd

pd.pivot_table(df, index=&quot;ID&quot;, columns=&quot;Date&quot;, aggfunc=&quot;count&quot;)