diff --git a/yli/utils.py b/yli/utils.py index 6986dfa..be6375f 100644 --- a/yli/utils.py +++ b/yli/utils.py @@ -1,5 +1,5 @@ # scipy-yli: Helpful SciPy utilities and recipes -# Copyright © 2022 Lee Yingtong Li (RunasSudo) +# Copyright © 2022–2025 Lee Yingtong Li (RunasSudo) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -362,14 +362,10 @@ def cols_for_formula(formula, df): name = factor.name() if name.startswith('C('): # Contrasts expression - # Get the corresponding factor_info - factor_info = formula_get_factor_info(formula, df, name) - - # Evaluate the factor - categorical_box = factor_info.factor.eval(factor_info.state, df) - - # Get the column name - name = categorical_box.data.name + if ',' in name: + name = name[2:name.index(',')] + else: + name = name[2:name.index(')')] cols.add(name)