import numpy as np
import pandas as pd
# Tutorial on how to export Google Calendar to csv - use the Calendar to Sheet extension:
# https://blog.coupler.io/export-google-calendar-to-google-sheets/#Why_you_would_need_to_export_data_from_your_Google_Calendar_to_Sheets
df = pd.read_csv("calendar.csv")
# Select all rows lower than 12 hours - over 12 hour events are likely to not be real events (but reminders, etc)
df= df[df['DURATION'] < 12]
# Select certain keywords and eliminate rows with these keywords - these are non-work events, etc.
searchfor = ['DINNER', 'COFFEE', 'ETC.']
# Delete rows with keywords above
df = df[~df.DESCRIPTION.str.contains('|'.join(searchfor))]
df = df.iloc[: , 1:]
df['DESCRIPTION'] = df['DESCRIPTION'].astype(str)
df = df.assign(CATEGORY="")
## These are my categories
# 1:1s
# Growth
# Product
# Research & Learning
# Future
# Culture
# Recruiting
# Investor Relations
# Manager / Admin
# Networking
# Tag meetings based on keywords - add all your keywords here; change categories if needed
searchfor_1on1 = ['1:1', 'OTHER_KEYWORDS_RELATED_TO_1_ON_1s']
searchfor_growth = ['GROWTH']
searchfor_research = ['JOURNAL CLUB', 'RESEARCH']
searchfor_future = ['NEW_PROJECT_1']
searchfor_culture = ['WEEKLY ALL-HANDS', 'MISSION']
searchfor_recruiting = ['INTERVIEW', 'PANEL', 'HIRING']
searchfor_investors = ['INVESTOR_NAMES']
searchfor_admin = ['WEEKLY LEADERSHIP CALL']
searchfor_networking = ['COFFEE']
searchfor_coding = ['CODING', 'WRITE CODE', 'PROGRAMMING']
searchfor_product = ['PRODUCT_REVIEW']
searchfor_fundraising = ['DECK']
# This removes rows that match the keywords above
# There's likely a more efficient way to do this but I had limited time :)
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_1on1)), 'CATEGORY'] = '1:1s'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_growth)), 'CATEGORY'] = 'Growth'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_research)), 'CATEGORY'] = 'Research & learning'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_future)), 'CATEGORY'] = 'Future'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_culture)), 'CATEGORY'] = 'Culture'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_recruiting)), 'CATEGORY'] = 'Recruiting'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_investors)), 'CATEGORY'] = 'Investor Relations'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_admin)), 'CATEGORY'] = 'Manager & Admin'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_networking)), 'CATEGORY'] = 'Networking'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_coding)), 'CATEGORY'] = 'Coding'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_product)), 'CATEGORY'] = 'Product'
df.loc[df['DESCRIPTION'].str.contains('|'.join(searchfor_fundraising)), 'CATEGORY'] = 'Fundraising'
# Create a temp dataframe to check which rows don't have a category yet
tmp = df[df['CATEGORY'].str.len() == 0]
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
display(df)
## How did I spend my time?
# Creates pie chart based on the category column
df.groupby(['CATEGORY']).sum().plot(kind='pie', subplots=True, figsize=(15,10), autopct='%1.1f%%')
## How many meetings did I have?
index = df.index
no_of_meetings = len(index)
print(f"Number of meetings: {no_of_meetings}")
## How much time did I spend in meetings?
meeting_hours = int(df['DURATION'].sum())
total_work_hours = 50*5*8
percentage_time_in_meetings = "{:.0%}".format(meeting_hours/total_work_hours)
print(f"Total no. of hours in meetings: {meeting_hours}")
print(f"Percentage of time in meetings: {percentage_time_in_meetings}")
## How many meetings / day, on average?
work_days = 50*5
meetings_per_day = no_of_meetings/work_days
print(f"Meetings per day: {meetings_per_day}")
## Plot days by number of meetings
df['START'] = pd.to_datetime(df['START'])
df['WEEKDAY'] = df['START'].dt.day_name()
df.groupby(['WEEKDAY']).sum().plot(kind='bar', subplots=True, figsize=(15,10))