time_utils

The data.time_utils module provides utility functions for querying time information.

Functions

wikirepo.data.time_utils.interval_to_col_name(interval)[source]

Queries the proper name of the column for timespans given an interval.

wikirepo.data.time_utils.truncate_date(d, interval=None)[source]

Truncates a date object given an interval.

wikirepo.data.time_utils.truncate_date_col(df, col, interval)[source]

Truncates the date column of a df based on a provided interval.

wikirepo.data.time_utils.incl_intervals()[source]

Queries the included intervals.

Note: timespans will not be able to be queried if their interval is not included.

wikirepo.data.time_utils.make_timespan(timespan=None, interval=None)[source]

Queries a timespan given user input of strings, ints, or time values.

Parameters:
timespantwo element tuple or listcontains datetime.date or tuple (default=None: (date.today(), date.today()))

A tuple or list that defines the start and end dates to be queried.

Note 1: if True, then the full timespan from 1-1-1 to the current day will be queried.

Note 2: passing a single entry will query for that date only.

intervalstr

The time interval over which queries will be made.

Note 1: see data.time_utils for options.

Note 2: if None, then only the most recent data will be queried.

Returns:
formatted_timespanlist (contains datetime.date)

The timespan formatted going back in time.

wikirepo.data.time_utils.latest_date(timespan)[source]

Returns the latest date in a timespan.

wikirepo.data.time_utils.earliest_date(timespan)[source]

Returns the earliest date in a timespan.

wikirepo.data.time_utils.truncated_latest_date(timespan, interval)[source]

Returns the truncated latest date in a timespan.

wikirepo.data.time_utils.truncated_earliest_date(timespan, interval)[source]

Returns the truncated earliest date in a timespan.