Datewise Functions

datewise.identify_date_format(date: str | datetime | Timestamp) str[source]

Identify date format of input date based on pre-determined widely used formats.

Parameters:

date (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – The date given by a user to identify it’s format

Returns:

Date format, if available, else message about error

Return type:

str

datewise.date_comparison(date_1: str | datetime | Timestamp, date_2: str | datetime | Timestamp, operation: str) bool[source]

Compare two dates given by a surer based on chosen comparison operator

Parameters:
  • date1 (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – Date no. 1 given by a user to be compared

  • date2 (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – Date no. 2 given by a user to be compared

  • operation (str) – Any valid comparison sign in string format

Returns:

True or False value based on a result

Return type:

bool

datewise.week_start(date: str | datetime | Timestamp) str[source]

Find the start of the specific week based on a given date

Parameters:

date (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – The date given by a user to identify start of the week that the date is in

Returns:

Date representing start of the week

Return type:

str

datewise.week_end(date: str | datetime | Timestamp, weekend: bool) str[source]

Find the end of the specific week based on a given date for either week as a whole or business week

Parameters:
  • date (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – The date given by a user to identify end of the week that the date is in

  • weekend (bool) – identifier for including or excluding weekend (standard or business week)

Returns:

Date representing end of the full or business week

Return type:

str

datewise.date_operations(date: str | datetime | Timestamp, operation: str, frequency: str, range: int, weekend: bool) str[source]

Adding or subtracting date for chosen frequency in specific range for either standard or business week

Parameters:
  • date (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – date from which subtraction or addition will be calculated

  • operation (str) – subtraction or addition

  • frequency (str) – type of periodicity –> day/month/year

  • range (int) – number of days/months/year to be added/subtracted to/from a date

  • weekend (bool) – identifier for including or excluding weekend (standard or business week)

Returns:

New day after subtraction or addition

Return type:

str

datewise.range_calculation(start: str | datetime | Timestamp, end: str | datetime | Timestamp, weekend: bool, frequency: str) list[source]

Calculate range between two dates for standard or business week in different frquencies

Parameters:
  • start (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – start of the period

  • end (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – end of the period

  • weekend (bool) – identifier for including or excluding weekend (standard or business week)

  • frequency (str) – type of periodicity –> day/month/year

Returns:

Range of days/months/year between two given dates

Return type:

list

datewise.date_convert(date: str | datetime | Timestamp, desired_type: str, format: str)[source]

Date conversion based on specified format according do tright party library options

Parameters:
  • date (str, datetime, pd._libs.tslibs.timestamps.Timestamp) – date for conversion

  • desired_type (str) – desired conversion format

  • format (str) – valid date format to be new date converted into

Returns:

Converted date

Return type:

str, datetime, pd._libs.tslibs.timestamps.Timestamp