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
|
# 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
|
# 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
|
# 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()
|
name = factor.name()
|
||||||
if name.startswith('C('):
|
if name.startswith('C('):
|
||||||
# Contrasts expression
|
# Contrasts expression
|
||||||
# Get the corresponding factor_info
|
if ',' in name:
|
||||||
factor_info = formula_get_factor_info(formula, df, name)
|
name = name[2:name.index(',')]
|
||||||
|
else:
|
||||||
# Evaluate the factor
|
name = name[2:name.index(')')]
|
||||||
categorical_box = factor_info.factor.eval(factor_info.state, df)
|
|
||||||
|
|
||||||
# Get the column name
|
|
||||||
name = categorical_box.data.name
|
|
||||||
|
|
||||||
cols.add(name)
|
cols.add(name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user