<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Table of Contents
<p><div class="lev1 toc-item"><a href="#Authenticate" data-toc-modified-id="Authenticate-1"><span class="toc-item-num">1&nbsp;&nbsp;</span>Authenticate</a></div><div class="lev2 toc-item"><a href="#what-do-you-need" data-toc-modified-id="what-do-you-need-11"><span class="toc-item-num">1.1&nbsp;&nbsp;</span>what do you need</a></div><div class="lev1 toc-item"><a href="#defining-helpers" data-toc-modified-id="defining-helpers-2"><span class="toc-item-num">2&nbsp;&nbsp;</span>defining helpers</a></div><div class="lev1 toc-item"><a href="#overview-of-calendars" data-toc-modified-id="overview-of-calendars-3"><span class="toc-item-num">3&nbsp;&nbsp;</span>overview of calendars</a></div><div class="lev1 toc-item"><a href="#push-events-to-calendar" data-toc-modified-id="push-events-to-calendar-4"><span class="toc-item-num">4&nbsp;&nbsp;</span>push events to calendar</a></div><div class="lev2 toc-item"><a href="#read-and-transform-df" data-toc-modified-id="read-and-transform-df-41"><span class="toc-item-num">4.1&nbsp;&nbsp;</span>read and transform df</a></div>
# Authenticate
another Disclaimer
Step1:  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
Step2:  overview of calendars
Step3:  hint
Step4:  push events to calendar
read and transform df
No big deal
<ASSISTANT_TASK:>
Python Code:
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
SCOPES = 'https://www.googleapis.com/auth/calendar'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Google Calendar API Python Quickstart'
import argparse
from argparse import Namespace
flags = None
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.credentials')
if not os.path.exists(credential_dir):
    os.makedirs(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,
    Namespace(
        auth_host_name='localhost', auth_host_port=[8080, 8090],
        logging_level='ERROR', noauth_local_webserver=False))
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', credentials=credentials)
Explanation: Table of Contents
<p><div class="lev1 toc-item"><a href="#Authenticate" data-toc-modified-id="Authenticate-1"><span class="toc-item-num">1&nbsp;&nbsp;</span>Authenticate</a></div><div class="lev2 toc-item"><a href="#what-do-you-need" data-toc-modified-id="what-do-you-need-11"><span class="toc-item-num">1.1&nbsp;&nbsp;</span>what do you need</a></div><div class="lev1 toc-item"><a href="#defining-helpers" data-toc-modified-id="defining-helpers-2"><span class="toc-item-num">2&nbsp;&nbsp;</span>defining helpers</a></div><div class="lev1 toc-item"><a href="#overview-of-calendars" data-toc-modified-id="overview-of-calendars-3"><span class="toc-item-num">3&nbsp;&nbsp;</span>overview of calendars</a></div><div class="lev1 toc-item"><a href="#push-events-to-calendar" data-toc-modified-id="push-events-to-calendar-4"><span class="toc-item-num">4&nbsp;&nbsp;</span>push events to calendar</a></div><div class="lev2 toc-item"><a href="#read-and-transform-df" data-toc-modified-id="read-and-transform-df-41"><span class="toc-item-num">4.1&nbsp;&nbsp;</span>read and transform df</a></div>
# Authenticate
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](https://developers.google.com/calendar/quickstart/python?authuser=1) 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](https://developers.google.com/calendar/quickstart/python?authuser=1#step_1_turn_on_the_api_name). The normal use of the API is free.
End of explanation
from helpers import *
Explanation: 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)
End of explanation
now = datetime.datetime.utcnow().isoformat() + 'Z'
CONFERENCE_START = '2018-07-06'
LEVEL_LIST = ['pydata_novice', 'pydata_intermediate', 'pydata_experienced']
Explanation: overview of calendars
End of explanation
create_pydata_calendars(service=service)
reduce_to_summary(get_cals(service, LEVEL_LIST))
cals = get_cals(service, LEVEL_LIST)
Explanation: 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.
End of explanation
df = pd.read_json('./data.json')[
    [
        'description', 'title', 'day_info', 'level',
        'room_inf', 'speaker', 'time_from', 'time_to'
    ]]
df.rename(
    columns={
        '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'] = df.day_info.map(
    {
        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
df.head(2)
for (_, event) in df.iterrows():
    write_event(event, cals, service)
Explanation: push events to calendar
read and transform df
No big deal: some renamings for the google API, mapping to right date format
End of explanation
<END_TASK>