emails has columns email_id, to_user and day. activity has
columns user_id, session_id and day.
For every (user, day) pair appearing in either table, count the emails that user received and the distinct sessions they opened, treating an absent side as 0. Return the Pearson correlation between those two counts as a float.
A user-day present in one table and missing from the other is a real zero, not a row to drop, and dropping them would change the answer.
Input
emails =
email_id to_user day
0 1 u1 1
1 2 u1 1
2 3 u2 1
3 4 u3 2
activity =
user_id session_id day
0 u1 10 1
1 u1 11 1
2 u2 12 1
3 u2 12 1
4 u4 13 1
Output
0.5