ts_shape.features.stats.timestamp_stats
Classes
| Name | Description |
|---|
TimestampStatistics | Provides class methods to calculate statistics on timestamp columns in a pandas DataFrame. |
Bases: Base
Provides class methods to calculate statistics on timestamp columns in a pandas DataFrame.
The default column for calculations is 'systime'.
Functions
count_null(dataframe: pd.DataFrame, time_column: str = 'systime') -> int
Returns the number of null (NaN) values in the timestamp column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
int | Number of missing timestamps. |
count_not_null(dataframe: pd.DataFrame, time_column: str = 'systime') -> int
Returns the number of non-null (valid) timestamps in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
int | Number of valid timestamps. |
earliest_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp
Returns the earliest timestamp in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timestamp | The earliest timestamp; NaT when there is none. |
latest_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp
Returns the latest timestamp in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timestamp | The latest timestamp; NaT when there is none. |
timestamp_range(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta
Returns the time range (difference) between the earliest and latest timestamps.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timedelta | Latest minus earliest timestamp; NaT when there is none. |
most_frequent_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp | None
Returns the most frequent timestamp in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timestamp | None | The most frequent timestamp (the earliest on a tie), or None when the column holds no timestamp. |
count_most_frequent_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> int
Returns the count of the most frequent timestamp in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
int | Occurrences of the most frequent timestamp; 0 when there is none. |
year_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series
Returns the distribution of timestamps per year.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Series | Series of timestamp counts indexed by year, most frequent first. |
month_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series
Returns the distribution of timestamps per month.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Series | Series of timestamp counts indexed by month number (1-12), most frequent first. |
weekday_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series
Returns the distribution of timestamps per weekday.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Series | Series of timestamp counts indexed by weekday (0=Monday, 6=Sunday), most frequent first. |
hour_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series
Returns the distribution of timestamps per hour of the day.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Series | Series of timestamp counts indexed by hour (0-23), most frequent first. |
most_frequent_day(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> int | None
Returns the most frequent day of the week (0=Monday, 6=Sunday).
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
int | None | The most frequent weekday (0=Monday; the smallest on a tie), or None when there is no timestamp. |
most_frequent_hour(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> int | None
Returns the most frequent hour of the day (0-23).
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
int | None | The most frequent hour (0-23; the smallest on a tie), or None when there is no timestamp. |
average_time_gap(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta
Returns the average time gap between consecutive timestamps.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timedelta | Mean gap between consecutive timestamps (in time order); NaT for fewer than 2 timestamps. |
median_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp
Returns the median timestamp in the column.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timestamp | The median timestamp; NaT when there is none. |
standard_deviation_timestamps(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta
Returns the standard deviation of the time differences between consecutive timestamps.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Timedelta | Standard deviation of the gaps between consecutive timestamps; NaT for fewer than 3 timestamps. |
timestamp_quartiles(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series
Returns the 25th, 50th (median), and 75th percentiles of the timestamps.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
Returns
| Type | Description |
|---|
Series | Series of the 25th, 50th and 75th percentile timestamps, indexed by quantile. |
days_with_most_activity(
dataframe: pd.DataFrame, time_column: str = "systime", n: int = 3
) -> pd.Series
Returns the top N days with the most timestamp activity.
Parameters
| Name | Type | Description | Default |
|---|
dataframe | DataFrame | Input DataFrame. | required |
time_column | str | Name of the timestamp column to analyze. Default "systime". | 'systime' |
n | int | Number of days to return. Default 3. | 3 |
Returns
| Type | Description |
|---|
Series | Series of timestamp counts indexed by calendar date, most active first. |