File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 7
7
Changelog
8
8
=========
9
9
10
- 4.0.1 - 2024-06-25
10
+ 4.1.0 - unreleased
11
11
------------------
12
12
13
13
**New feature: **
14
14
15
15
- Added a new function, :func: `tabmat.from_polars `, to convert a :class: `polars.DataFrame ` into a :class: `tabmat.SplitMatrix `.
16
16
17
+ 4.0.1 - 2024-06-25
18
+ ------------------
19
+
17
20
**Other changes: **
18
21
19
22
- Removed reference to the ``.A `` attribute and replaced it with ``.toarray() ``.
Original file line number Diff line number Diff line change 28
28
pd = None
29
29
30
30
31
+ def _is_boolean (series , engine : str ):
32
+ if engine == "pandas" :
33
+ return pd .api .types .is_bool_dtype (series )
34
+ elif engine == "polars" :
35
+ return series .dtype .is_ (pl .Boolean )
36
+ else :
37
+ raise ValueError (f"Unknown engine: { engine } " )
38
+
39
+
31
40
def _is_numeric (series , engine : str ):
32
41
if engine == "pandas" :
33
42
return pd .api .types .is_numeric_dtype (series )
@@ -154,6 +163,15 @@ def _from_dataframe(
154
163
mxcolidx += cat .shape [1 ]
155
164
elif cat_position == "end" :
156
165
indices .append (np .arange (cat .shape [1 ]))
166
+ elif _is_boolean (coldata , engine ):
167
+ if (coldata != False ).mean () <= sparse_threshold : # noqa E712
168
+ sparse_dfidx .append (dfcolidx )
169
+ sparse_tmidx .append (mxcolidx )
170
+ mxcolidx += 1
171
+ else :
172
+ dense_dfidx .append (dfcolidx )
173
+ dense_tmidx .append (mxcolidx )
174
+ mxcolidx += 1
157
175
elif _is_numeric (coldata , engine ):
158
176
if (coldata != 0 ).mean () <= sparse_threshold :
159
177
sparse_dfidx .append (dfcolidx )
You can’t perform that action at this time.
0 commit comments