string_stats
string_stats ¤
StringStatistics ¤
StringStatistics(
dataframe: DataFrame, time_column: str = "systime"
)
Bases: Base
Provides class methods to calculate statistics on string columns in a pandas DataFrame.
count_unique
classmethod
¤
count_unique(
dataframe: DataFrame, value_column: str = "value_string"
) -> int
Returns the number of unique strings in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Number of distinct non-null values. |
most_frequent
classmethod
¤
most_frequent(
dataframe: DataFrame, value_column: str = "value_string"
) -> str | None
Returns the most frequent string in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
str | None
|
The most frequent non-null string (the smallest on ties), or |
str | None
|
|
count_most_frequent
classmethod
¤
count_most_frequent(
dataframe: DataFrame, value_column: str = "value_string"
) -> int
Returns the count of the most frequent string in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Occurrences of :meth: |
int
|
no non-null value (it raised |
count_null
classmethod
¤
count_null(
dataframe: DataFrame, value_column: str = "value_string"
) -> int
Returns the number of null (NaN) values in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Number of missing values. |
average_string_length
classmethod
¤
average_string_length(
dataframe: DataFrame, value_column: str = "value_string"
) -> float
Returns the average length of strings in the column, excluding null values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
float
|
Mean length of the non-null strings; NaN when there is none. |
longest_string
classmethod
¤
longest_string(
dataframe: DataFrame, value_column: str = "value_string"
) -> str | None
Returns the longest string in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
str | None
|
The longest non-null string, or |
str | None
|
non-null value. |
shortest_string
classmethod
¤
shortest_string(
dataframe: DataFrame, value_column: str = "value_string"
) -> str | None
Returns the shortest string in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
str | None
|
The shortest non-null string, or |
str | None
|
non-null value. |
string_length_summary
classmethod
¤
string_length_summary(
dataframe: DataFrame, value_column: str = "value_string"
) -> pd.DataFrame
Returns a summary of string lengths, including min, max, and average lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
One-row DataFrame with columns |
most_common_n_strings
classmethod
¤
most_common_n_strings(
dataframe: DataFrame,
n: int,
value_column: str = "value_string",
) -> pd.Series
Returns the top N most frequent strings in the column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
n
|
int
|
Number of strings to return. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
Series
|
Series of counts indexed by string, most frequent first. |
contains_substring_count
classmethod
¤
contains_substring_count(
dataframe: DataFrame,
substring: str,
value_column: str = "value_string",
*,
regex: bool = False
) -> int
Counts how many strings contain the specified substring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
substring
|
str
|
Text to look for, matched literally by default, so
characters such as |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
regex
|
bool
|
If False (default), match |
False
|
Returns:
| Type | Description |
|---|---|
int
|
Number of non-null strings that contain |
starts_with_count
classmethod
¤
starts_with_count(
dataframe: DataFrame,
prefix: str,
value_column: str = "value_string",
) -> int
Counts how many strings start with the specified prefix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
prefix
|
str
|
Prefix to match. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Number of non-null strings that start with |
ends_with_count
classmethod
¤
ends_with_count(
dataframe: DataFrame,
suffix: str,
value_column: str = "value_string",
) -> int
Counts how many strings end with the specified suffix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
suffix
|
str
|
Suffix to match. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Number of non-null strings that end with |
uppercase_percentage
classmethod
¤
uppercase_percentage(
dataframe: DataFrame, value_column: str = "value_string"
) -> float
Returns the percentage of strings that are fully uppercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
float
|
Percentage (0-100) of the non-null strings that are fully uppercase; NaN when the column holds no non-null value. |
lowercase_percentage
classmethod
¤
lowercase_percentage(
dataframe: DataFrame, value_column: str = "value_string"
) -> float
Returns the percentage of strings that are fully lowercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
float
|
Percentage (0-100) of the non-null strings that are fully lowercase; NaN when the column holds no non-null value. |
contains_digit_count
classmethod
¤
contains_digit_count(
dataframe: DataFrame, value_column: str = "value_string"
) -> int
Counts how many strings contain digits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. Default
|
'value_string'
|
Returns:
| Type | Description |
|---|---|
int
|
Number of non-null strings with at least one digit. |
summary_as_dict
classmethod
¤
summary_as_dict(
dataframe: DataFrame, value_column: str
) -> dict[str, int | str | float | None]
Returns a dictionary with comprehensive string statistics for the specified column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int | str | float | None]
|
Dict with keys |
summary_as_dataframe
classmethod
¤
summary_as_dataframe(
dataframe: DataFrame, value_column: str
) -> pd.DataFrame
Returns a DataFrame with comprehensive string statistics for the specified column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame. |
required |
value_column
|
str
|
Name of the string column to analyze. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
One-row DataFrame with the keys of |