We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 740954b commit 5f65c92Copy full SHA for 5f65c92
1 file changed
spinetoolbox/plotting.py
@@ -116,12 +116,17 @@ class ParameterTableHeaderSection:
116
117
# Regex pattern to indentify numerical sequences encoded as string
118
SEQ_PAT = re.compile(r"^([a-zA-Z])([0-9]+)$")
119
+STR_TYPES = (
120
+ object,
121
+ pd.StringDtype(na_value=pd.NA),
122
+ pd.StringDtype(na_value=np.nan),
123
+)
124
125
126
def parse_time(df: pd.DataFrame) -> pd.DataFrame:
127
"""Parse 'time' or 'period' columns to integers for plotting."""
128
for col, _type in df.dtypes.items():
- if _type in (object, pd.StringDtype()) and (groups := df[col].str.extract(SEQ_PAT)).notna().all(axis=None):
129
+ if _type in STR_TYPES and (groups := df[col].str.extract(SEQ_PAT)).notna().all(axis=None):
130
df[col] = groups[1].astype(int)
131
return df
132
0 commit comments