Skip to content

isaacarnault/2019-Calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dates estimator using Python

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

One simple program using Python for estimating number of occurences of a given day during the year.
E.g:

  • use this program if you want to estimate a specific day of a given year.
  • in our program we'll try to guess all fridays of the year 2019
  • Refer to dates_estimator.py for the program and to exercise_solution.py for a solution

Getting Started

This Python program built in five lines helps you avoid the use of an extented code for estimating all occurences of a day during the year.

  • (#) and (''') are used to comment the following gist.

Prerequisites

I am using Jupyter Notebook on localhost (Ubuntu 18.04 bionic).
Make sure to have Jupyter Notebook installed on your operating system or launch it on remote servers (see Tips).

Tips

If you are not using Linux/Unix and still want to try this simple Python program:

Basic commands in Jupyter Notebook

  • Note that in Jupyter you add new lines by typing "b" from your keyboard whilst the notebook is opened.
  • Avoid runing the entire code in a single cell in order to understand the steps.
  • Use "ctrl + enter" to execute each line if you want to get the output.
  • Use "dd" outside a cell to delete it.
  • Use "a" outside a cell to add a new cell above it.
  • Use "b" outside as cell to add a new cell below it.
  • Running the last cell should execute the permutations as program output.

Whilst your Python Notebook is open... Use this line of code in your first cell

import pandas as pd

'''
This loads requested package
and library in your notebook
'''

Use this lines of code in your second cell

def allfridays(year):
    return pd.date_range(start=str(year), end=str(year+1),
                         freq='W-FRI').strftime('%m/%d/%Y').tolist()

allfridays(2019)[:52]

'''
This will print out all fridays of the year 2019. Note that we've set the program to run on 52 weeks of a regular year. You can set the program to any number of weeks or to another year.
'''

Running the tests

  • I used Ubuntu (18.04 bionic) to launch Jupyter Notebook on localhost.
  • Localhost instantiates while using $ jupyter notebook in the terminal.
  • Check if Jupyter is correctly installed: $ jupyter --version

Built With

  • Jupyter - An open source software for creating notebooks
  • Pandas - A high-level data manipulation tool developed by Wes McKinney

Versioning

I used no vesioning system for this gist, which repos status is flagged as concept because it is intended to be a demo or POC (proof-of-concept).

Author

  • Isaac Arnault - Suggesting a minified code from Initial work zhenyi2697

License

All public gists https://gist.github.com/isaacarnault
Copyright 2018, Isaac Arnault
MIT License, http://www.opensource.org/licenses/mit-license.php

Exercise

Write a simple Python programm that outputs:

  • full date and time of the current day (as shown by your Linux shell using $ date)
  • current year
  • current month
  • current week number
  • current day in the current week

About

Dates estimator using Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages