<jupyter_start><jupyter_text>Pomodora Timer Exercise - 100 days of code days 1-3<jupyter_code>%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
from datetime import timedelta
from datetime import date
import pandas as pd
def make_pomlist(duration):
    duration_min = duration.total_seconds()/60
    time_remaining = duration_min
    current_time = datetime.now()
    schedule = []
    n_sessions = 0
    while time_remaining > 0:
        n_sessions += 1
        if time_remaining > 25:
            session_time = 25
            time_remaining -= 25
            schedule.append([n_sessions,"study",str(current_time),str(current_time + timedelta(minutes=25)),str(25) + " min"])
            current_time = current_time + timedelta(minutes=25)
        else:
            session_time = time_remaining
            time_remaining = 0
            schedule.append([n_sessions,"study",str(current_time),str(current_time + timedelta(minutes=session_time)), str(session_time) + " min"])
            break
        if n_sessions % 4 != 0:
            break_time = 5
        else:
            break_time = 30
        if time_remaining - break_time > 0:
            time_remaining -= break_time
            schedule.append([n_sessions,"breaktime",str(current_time),str(current_time + timedelta(minutes=break_time)),str(break_time) + " min"])
            current_time = current_time + timedelta(minutes=break_time)
        else:
            break_time = time_remaining
            time_remaining = 0
            schedule.append([n_sessions,"breaktime",str(current_time),str(current_time + timedelta(minutes=break_time)), str(break_time) + " min"])
            break
    return schedule
schedule = make_pomlist(timedelta(hours=4, minutes=30, seconds=45))
df = pd.DataFrame(schedule, columns=['Task','Resource','Start','Finish','Duration'])
print(df.to_string(index=False))
df2 = df[['Task','Resource','Start','Finish']]
import plotly
# plotly.tools.set_credentials_file(username='ed.luschei', api_key='nAFQffJf6U3llxlr4zKp')
import plotly.plotly as py
import plotly.figure_factory as ff
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
colors = dict(study='rgb(34,139,34)', 
              breaktime='rgb(255,0,0)')
fig = ff.create_gantt(df2, colors=colors, index_col='Resource', title='Study Schedule (Pomodoro)',
                      show_colorbar=True, bar_width=0.5, showgrid_x=True, showgrid_y=True)
py.iplot(fig, filename='pomodora-schedule')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11218195836545874, 'fraction_numerical': 0.02081727062451812, 'mean_word_length': 3.7181818181818183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '332049', 'license': 'MIT', 'n_tokens_mistral': 867, 'n_tokens_neox': 805, 'n_words': 154, 'path': 'notebooks/pomodoro-timer.ipynb', 'repo_name': 'edluschei/100daysofcode-with-python-course', 'size': '2594'}