File tree Expand file tree Collapse file tree 2 files changed +6
-13
lines changed
Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -42,9 +42,13 @@ def set_int_index(series: pd.Series) -> pd.Series:
4242 """
4343 Convert string index to int index.
4444 """
45+
4546 if not series .empty and not pd .api .types .is_integer_dtype (series .index ):
4647 cutoff = count_initial_letters (str (series .index [0 ]))
47- series .index = series .index .str [cutoff :].astype (int )
48+ try :
49+ series .index = series .index .str [cutoff :].astype (int )
50+ except ValueError :
51+ series .index = series .index .str .replace (".*#" , "" , regex = True ).astype (int )
4852 return series
4953
5054
Original file line number Diff line number Diff line change 1515import sys
1616from abc import ABC , abstractmethod
1717from pathlib import Path
18- from typing import TYPE_CHECKING , Callable , Sequence
18+ from typing import TYPE_CHECKING , Callable
1919
2020import numpy as np
2121import pandas as pd
133133)
134134
135135
136- def set_int_index (series : Series ) -> Series :
137- """
138- Convert string index to int index.
139- """
140- try :
141- series .index = series .index .str [1 :].astype (int )
142- except ValueError as _ :
143- series .index = series .index .str .replace (".*#" , "" , regex = True ).astype (int )
144- return series
145-
146-
147136# using enum to match solver subclasses with names
148137class SolverName (enum .Enum ):
149138 CBC = "cbc"
You can’t perform that action at this time.
0 commit comments