Skip to main content
Version: 0.0.98

ts_shape.features.stats.timestamp_stats

Classes
NameDescription
TimestampStatisticsProvides class methods to calculate statistics on timestamp columns in a pandas DataFrame.

TimestampStatistics​

classsource

Bases: Base

Provides class methods to calculate statistics on timestamp columns in a pandas DataFrame. The default column for calculations is 'systime'.

Functions
NameDescription
count_nullReturns the number of null (NaN) values in the timestamp column.
count_not_nullReturns the number of non-null (valid) timestamps in the column.
earliest_timestampReturns the earliest timestamp in the column.
latest_timestampReturns the latest timestamp in the column.
timestamp_rangeReturns the time range (difference) between the earliest and latest timestamps.
most_frequent_timestampReturns the most frequent timestamp in the column.
count_most_frequent_timestampReturns the count of the most frequent timestamp in the column.
year_distributionReturns the distribution of timestamps per year.
month_distributionReturns the distribution of timestamps per month.
weekday_distributionReturns the distribution of timestamps per weekday.
hour_distributionReturns the distribution of timestamps per hour of the day.
most_frequent_dayReturns the most frequent day of the week (0=Monday, 6=Sunday).
most_frequent_hourReturns the most frequent hour of the day (0-23).
average_time_gapReturns the average time gap between consecutive timestamps.
median_timestampReturns the median timestamp in the column.
standard_deviation_timestampsReturns the standard deviation of the time differences between consecutive timestamps.
timestamp_quartilesReturns the 25th, 50th (median), and 75th percentiles of the timestamps.
days_with_most_activityReturns the top N days with the most timestamp activity.

count_null​

classmethodsource
count_null(dataframe: pd.DataFrame, time_column: str = 'systime') -> int

Returns the number of null (NaN) values in the timestamp column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
intNumber of missing timestamps.

count_not_null​

classmethodsource
count_not_null(dataframe: pd.DataFrame, time_column: str = 'systime') -> int

Returns the number of non-null (valid) timestamps in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
intNumber of valid timestamps.

earliest_timestamp​

classmethodsource
earliest_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp

Returns the earliest timestamp in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimestampThe earliest timestamp; NaT when there is none.

latest_timestamp​

classmethodsource
latest_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp

Returns the latest timestamp in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimestampThe latest timestamp; NaT when there is none.

timestamp_range​

classmethodsource
timestamp_range(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta

Returns the time range (difference) between the earliest and latest timestamps.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimedeltaLatest minus earliest timestamp; NaT when there is none.

most_frequent_timestamp​

classmethodsource
most_frequent_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp | None

Returns the most frequent timestamp in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
Timestamp | NoneThe most frequent timestamp (the earliest on a tie), or None when the column holds no timestamp.

count_most_frequent_timestamp​

classmethodsource
count_most_frequent_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> int

Returns the count of the most frequent timestamp in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
intOccurrences of the most frequent timestamp; 0 when there is none.

year_distribution​

classmethodsource
year_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series

Returns the distribution of timestamps per year.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
SeriesSeries of timestamp counts indexed by year, most frequent first.

month_distribution​

classmethodsource
month_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series

Returns the distribution of timestamps per month.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
SeriesSeries of timestamp counts indexed by month number (1-12), most frequent first.

weekday_distribution​

classmethodsource
weekday_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series

Returns the distribution of timestamps per weekday.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
SeriesSeries of timestamp counts indexed by weekday (0=Monday, 6=Sunday), most frequent first.

hour_distribution​

classmethodsource
hour_distribution(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series

Returns the distribution of timestamps per hour of the day.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
SeriesSeries of timestamp counts indexed by hour (0-23), most frequent first.

most_frequent_day​

classmethodsource
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
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
int | NoneThe most frequent weekday (0=Monday; the smallest on a tie), or None when there is no timestamp.

most_frequent_hour​

classmethodsource
most_frequent_hour(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> int | None

Returns the most frequent hour of the day (0-23).

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
int | NoneThe most frequent hour (0-23; the smallest on a tie), or None when there is no timestamp.

average_time_gap​

classmethodsource
average_time_gap(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta

Returns the average time gap between consecutive timestamps.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimedeltaMean gap between consecutive timestamps (in time order); NaT for fewer than 2 timestamps.

median_timestamp​

classmethodsource
median_timestamp(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timestamp

Returns the median timestamp in the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimestampThe median timestamp; NaT when there is none.

standard_deviation_timestamps​

classmethodsource
standard_deviation_timestamps(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Timedelta

Returns the standard deviation of the time differences between consecutive timestamps.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
TimedeltaStandard deviation of the gaps between consecutive timestamps; NaT for fewer than 3 timestamps.

timestamp_quartiles​

classmethodsource
timestamp_quartiles(
dataframe: pd.DataFrame, time_column: str = "systime"
) -> pd.Series

Returns the 25th, 50th (median), and 75th percentiles of the timestamps.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
Returns
TypeDescription
SeriesSeries of the 25th, 50th and 75th percentile timestamps, indexed by quantile.

days_with_most_activity​

classmethodsource
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
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
time_columnstrName of the timestamp column to analyze. Default "systime".'systime'
nintNumber of days to return. Default 3.3
Returns
TypeDescription
SeriesSeries of timestamp counts indexed by calendar date, most active first.