You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
What is the current behavior?
When summing
FixedEffect
instances built from a Pandas DataFrame with converted dtypes, the function
remove_duplicate_columns
in
brainstat/stats/terms.py
raises the following error:
File ~/GitRepos/BrainStat/brainstat/stats/terms.py:243, in remove_duplicate_columns(df, tol)
241 df *= 1 / tol
242 # keep = df.round().T.drop_duplicates(keep="last").T.columns # Slow!!
--> 243 idx = np.unique(df.round().values, axis=1, return_index=True)[-1]
244 keep = df.columns[sorted(idx)]
245 return keep
TypeError: The axis argument to unique is not supported for dtype object
Please provide the steps to reproduce and if possible a minimal demo of the problem
.
Here is a MWE:
import pandas as pd
from brainstat.stats.terms import FixedEffect
df = pd.DataFrame({"age": [20.2, 33.1, 25.0],
"sex": ["Female", "Male", "Male"],
}).convert_dtypes()
df = df.apply(lambda x: x.astype('category') if x.name == "sex" else x)
FixedEffect(df.age) + FixedEffect(df.sex)
What is the expected behavior?
No crash.
Please tell us about your computing environment:
Python
3.9.11
Brainstat
0.3.6
Other information