Remove cols_for_formula dependency on patsy
This commit is contained in:
parent
1cc9aae3bd
commit
a09a84f9ef
14
yli/utils.py
14
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user