Date Manager
This page contains documentation for the
Date Manager
package which is curated with frequently used datetime methods,
modules in a simpler way.
Frequent date operations using methods provided.
Modules exported by this package:
date_manager
: Provide several frequently used datetime operations.
Package Details
This module allows the user to make datetime operations.
Examples:
>>> from date_manager.date_manager import DateManager
>>> date_manager = DateManager(log_file='abc.log')
>>> data = {'datetime_column': ['2022-01-01', '2022-01-02', '2022-01-03']}
>>> df = pd.DataFrame(data)
>>> df['datetime_column'] = pd.to_datetime(df['datetime_column'])
The module contains the following methods:
__init__(log_file)
- creates the instance of the class.timestamp_to_date(dataframe)
- returns the dataframe with all datetime column modified to date datatype.timestamp_to_date_column(column, dataframe)
- returns the dataframe with specific datetime column to date datatype.
DateManager
Source code in date_manager\date_manager.py
__init__(log_file='./Custom-Python_Tools.log')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_file |
str
|
The path to the log file. |
'./Custom-Python_Tools.log'
|
timestamp_to_date(dataframe)
Convert datetime columns in a dataframe to date type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
DataFrame
|
The dataframe containing the datetime columns. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: The input dataframe with the datetime columns converted to date type. |
Source code in date_manager\date_manager.py
timestamp_to_date_column(column, dataframe)
Convert a datetime column in a dataframe to date type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column |
str
|
The name of the datetime column to convert. |
required |
dataframe |
DataFrame
|
The dataframe containing the datetime column. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: The input dataframe with the datetime column converted to date type. |
Raises:
Type | Description |
---|---|
ValueError
|
If the input dataframe does not contain the specified datetime column. |