lux.utils package¶
Submodules¶
lux.utils.date_utils module¶
-
lux.utils.date_utils.
compute_date_granularity
(date_column: pandas.core.series.Series)[source]¶ Given a temporal column (pandas.core.series.Series), finds out the granularity of dates.
Example
[‘2018-01-01’, ‘2019-01-02’, ‘2018-01-03’] -> “day” [‘2018-01-01’, ‘2019-02-01’, ‘2018-03-01’] -> “month” [‘2018-01-01’, ‘2019-01-01’, ‘2020-01-01’] -> “year”
Parameters: date_column (pandas.core.series.Series) – Column series with datetime type Returns: field – A str specifying the granularity of dates for the inspected temporal column Return type: str
-
lux.utils.date_utils.
date_formatter
(time_stamp, ldf)[source]¶ Given a numpy timestamp and ldf, inspects which date granularity is appropriate and reformats timestamp accordingly
Example
For changing granularity the results differ as so. days: ‘2020-01-01’ -> ‘2020-1-1’ months: ‘2020-01-01’ -> ‘2020-1’ years: ‘2020-01-01’ -> ‘2020’
Parameters: - time_stamp (np.datetime64) – timestamp object holding the date information
- ldf (lux.core.frame) – LuxDataFrame with a temporal field
Returns: date_str – A reformatted version of the time_stamp according to granularity
Return type: str
-
lux.utils.date_utils.
is_datetime_series
(series: pandas.core.series.Series) → bool[source]¶ Check if the Series object is of datetime type
Parameters: series (pd.Series) – Returns: is_date Return type: bool
-
lux.utils.date_utils.
is_datetime_string
(string: str) → bool[source]¶ Check if the string is date-like.
Parameters: string (str) – Returns: is_date Return type: bool