biopsykit.utils.time module¶
Module containing helper functions to handle time data.
- biopsykit.utils.time.check_tz_aware(data)[source]¶
Check whether dataframe index is timezone-aware.
- Parameters
data (
DataFrame
) – dataframe with index to check- Returns
True
if index of dataframe is aDatetimeIndex
and index is timezone-aware,False
otherwise- Return type
- biopsykit.utils.time.extract_time_from_filename(file_path, filename_pattern, date_pattern=None)[source]¶
Extract time information from filename.
- Parameters
- Returns
extracted date information
- Return type
- biopsykit.utils.time.get_time_from_date(data, is_utc=False, tz_convert=False, timezone=None)[source]¶
Extract time information from series with date information.
Some functions expect only time information (hour, minute, second, …) without date information (year, month, day). This function can be used to extract only the relevant time information from the complete datetime data.
- Parameters
data (
Series
) – series with date informationis_utc (bool, optional) –
True
if datetime is in UTC,False
otherwise. Default:False
tz_convert (bool, optional) –
True
to convert datetime into correct timezone before extracting time information orFalse
to localize datetime. Default:False
timezone (str or
datetime.tzinfo
) – timezone the datetime objects are in or should be converted to. Default:None
, which defaults to time zone “Europe/Berlin”
- Returns
pandas series with time information extracted from datetime
- Return type
- biopsykit.utils.time.time_to_timedelta(data)[source]¶
Convert time information in a series into
datetime.timedelta
data.- Parameters
data (
Series
) – series with time information- Returns
series with data converted into
datetime.timedelta
- Return type
- biopsykit.utils.time.timedelta_to_time(data)[source]¶
Convert
datetime.timedelta
data in a seriesdatetime.time
data.- Parameters
data (
Series
) – series with data asdatetime.timedelta
- Returns
series with data converted into
datetime.time
- Return type