another Disclaimer: This is really ugly and often fails. Try to get it running, as the apiclient has got the service (this is the hard part), everything should work.

WARNING: oauth2client is outdated and no longer maintained. I still use it but you shouldn't. Unfortunately the calendar quickstart documentation uses it, so one has to put own effort in using more modern tools.

what do you need

Just one google account and you can follow the guide here. The normal use of the API is free.

In [1]:
from __future__ import print_function
import httplib2
import os

from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage

import datetime

CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Google Calendar API Python Quickstart'

import argparse
from argparse import Namespace

flags = None

In [2]:
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.credentials')
if not os.path.exists(credential_dir):
credential_path = os.path.join(
    credential_dir, 'calendar-python-quickstart.json')

store = Storage(credential_path)
credentials = store.get()

flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)

credentials = tools.run_flow(
    flow, store,
        auth_host_name='localhost', auth_host_port=[8080, 8090],
        logging_level='ERROR', noauth_local_webserver=False))

Your browser has been opened to visit:

If your browser is on a different machine then exit and re-run this
application with the command-line parameter


Authentication successful.

In [3]:
http = credentials.authorize(httplib2.Http())

In [4]:
service ='calendar', 'v3', credentials=credentials)

defining helpers

Yes, most of this code is not good. There are no good docstrings nor good code.

This is not a bug, it's an possibility to improve ;-)

Mainly, the helper file contains some convenience helpers and two important functions:

  • create_pydata_calendars (this creates the calendars if there is none with the same summary)
  • write_event (this creates the event if there is none with same time and summary)

In [13]:
from helpers import *

overview of calendars

In [6]:
now = datetime.datetime.utcnow().isoformat() + 'Z'
CONFERENCE_START = '2018-07-06'
LEVEL_LIST = ['pydata_novice', 'pydata_intermediate', 'pydata_experienced']

hint: the LEVEL_LIST can be created automatically from the dataframe of events later and then execute these functions later -> therefore you can also split by room instead of level if you want to have separate calendars for that.

In [7]:

{'pydata_experienced': u'',
 'pydata_intermediate': u'',
 'pydata_novice': u''}

In [8]:
reduce_to_summary(get_cals(service, LEVEL_LIST))

[u'pydata_intermediate', u'pydata_novice', u'pydata_experienced']

In [9]:
cals = get_cals(service, LEVEL_LIST)

push events to calendar

read and transform df

No big deal: some renamings for the google API, mapping to right date format

In [10]:
df = pd.read_json('./data.json')[
        'description', 'title', 'day_info', 'level',
        'room_inf', 'speaker', 'time_from', 'time_to'
        'title': 'summary',
        'room_inf': 'location',
        'speaker': 'attendees'
    }, inplace=True)

df.level = 'pydata_' + df.level.str.lower()

# mapping date (dayofweek) to right format for google calendar api values
df['date'] =
        ddd.strftime('%A'): ddd.strftime('%Y-%m-%dT')
        for ddd in pd.date_range(
            start=CONFERENCE_START, periods=df.day_info.nunique(), freq="D")})
df['start'] = df['date'] + df.time_from
df['end'] = df['date'] + df.time_to

In [11]:

description summary day_info level location attendees time_from time_to date start end
0 In many practical machine learning classificat... Using GANs to improve generalization in a semi... Friday pydata_intermediate Track 1 Andreas Merentitis 09:00:00 10:30:00 2018-07-06T 2018-07-06T09:00:00 2018-07-06T10:30:00
1 We’ve created a playground data science applic... A Hands-On Introduction to Your First Data Sci... Friday pydata_intermediate Track 2 Em Grasmeder 13:15:00 14:45:00 2018-07-06T 2018-07-06T13:15:00 2018-07-06T14:45:00

In [12]:
for (_, event) in df.iterrows():
    write_event(event, cals, service)

creating event Using GANs to improve generalization in a semi-supervised setting - trying it in open datasets
creating event A Hands-On Introduction to Your First Data Science Project
creating event ctparse: a practical parser for natural language time expressions in pure python
creating event Battle-hardened advice on efficient data loading for deep learning on videos.
creating event Where NLP and psychology meet
creating event Towards automating machine learning: benchmarking tools for hyperparameter tuning
creating event Python Unittesting for Ethereum Smart Contracts or how not to create your own Cryptocurrency
creating event LightFields.jl: Fast 3D image reconstruction for VR applications
creating event Object detection to Instance segmentation: Learn to apply several algorithms along the way
creating event Meaningful histogramming with Physt
creating event How to scare a fish (school)
creating event Simple diagrams of convoluted neural networks
creating event Leveling up your storytelling and visualization skills
creating event CatBoost: Fast Open-Source Gradient Boosting Library For GPU
creating event Practical examples of interactive visualizations in JupyterLab with Pixi.js and Jupyter Widgets
creating event On Laplacian Eigenmaps for Dimensionality Reduction
creating event Deep Neural Networks for Double Dummy at Bridge
creating event Extending Pandas using Apache Arrow and Numba
creating event Modern Approaches to Bayesian Learning with Neural Networks
creating event Understanding and Applying Self-Attention for NLP
creating event The Face of Nanomaterials: Insightful Classification Using Deep Learning
creating event Deprecating the state machine: building conversational AI with the Rasa stack
creating event Five things I learned from turning research papers into industry prototypes
creating event All that likelihood with PyMC3
creating event ML and populism
creating event GDPR in practise - Developing models with transparency and privacy in mind
creating event Spatial Data Analysis With Python
creating event Python in Medicine: analysing data from mechanical ventilators and patient monitors
creating event Industrial ML - Overview of the technologies available to build scalable machine learning
creating event Extracting relevant Metrics with Spectral Clustering
creating event Tricks, tips and topics in Text Analysis
creating event Simplifying Training Deep & Serving Learning Models with Big Data in Python using Tensorflow
creating event How I Made My Computer Write it's First Short Story
creating event Privacy-preserving Data Sharing
creating event Deploying a machine learning model to the cloud using AWS Lambda
creating event Manifold Learning and Dimensionality Reduction for Data Visualization and Feature Engineering
creating event pyGAM: balancing interpretability and predictive power using Generalized Additive Models in Python
creating event Launch Jupyter to the Cloud: an example of using Docker and Terraform
creating event How brings Data Science to Production for a Personalized Web Experience
creating event Scaling and reproducing deep learning on Kubernetes with Polyaxon
creating event Data versioning in machine learning projects
creating event Solving very simple substitution ciphers algorithmically
creating event A/B testing at Zalando: concepts and tools
creating event Deep Neural Networks with PyTorch
creating event Let's SQL Like It's 1992!
creating event When to go deep in Computer Vision... and how
creating event Surviving Interviews with Media (unrecorded)
creating event AI in Healthcare
creating event Production ready Data-Science with Python and Luigi
creating event Search Relevance: A/B testing to Reinforcement Learning
creating event Keynote: Hacking the Iron Curtain: From smuggling computer parts to owning the world
creating event Keynote:  Building in Privacy and Data Protection -- what is demanded by the GDPR?
creating event Keynote - Fairness and Diversity in Online Social Systems
creating event Building new NLP solutions with spaCy and Prodigy
creating event Making your first open source contribution
creating event Software Development Core Skills: `git`
creating event Going Full Stack with Data Science: Using Technical Readiness Level to Guide Data Science Outcomes
creating event Career Panel Hosted by Nakeema Stefflbauer (followed by Q&A)
creating event Big Data Systems Performance: The Little Shop of Horrors
creating event Interfacing R and Python
creating event Visual concept learning from few images