Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

toad.selection.select 可以处理字符串变量吗? #126

Open
hailee8899 opened this issue Jun 8, 2023 · 4 comments
Open

toad.selection.select 可以处理字符串变量吗? #126

hailee8899 opened this issue Jun 8, 2023 · 4 comments

Comments

@hailee8899
Copy link

官方文档 https://toad.readthedocs.io/en/latest/tutorial.html
这里的例子并没有说明不支持处理字符串变量。

但是我用了同样的代码和数据,从代码的报错信息来看是不支持的,请大家帮忙解答一下疑惑。

@Aryooo
Copy link

Aryooo commented Nov 2, 2023

同样的问题,甚至删掉所有字符串还是会报错

@AnnaYang2223
Copy link

我也遇到了这个问题,官方文档上的展示数据中不就有字符串类型的数据吗,但是我运行时报错
数据
下面是报错内容:
selected_data, drop_lst = toad.selection.select(
data_tr,target = 'TARGET',empty = 0.5,
iv=0.05, corr=0.7,return_drop=True
)
Traceback (most recent call last):

Cell In[15], line 1
selected_data, drop_lst = toad.selection.select(

File D:\anaconda3\Lib\site-packages\toad\selection.py:517 in select
frame, corr_drop = drop_corr(frame, target = target, threshold = corr, by = weights, return_drop = True, exclude = exclude)

File D:\anaconda3\Lib\site-packages\toad\selection.py:329 in drop_corr
corr = f.corr().abs()

File D:\anaconda3\Lib\site-packages\pandas\core\frame.py:10054 in corr
mat = data.to_numpy(dtype=float, na_value=np.nan, copy=False)

File D:\anaconda3\Lib\site-packages\pandas\core\frame.py:1838 in to_numpy
result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)

File D:\anaconda3\Lib\site-packages\pandas\core\internals\managers.py:1732 in as_array
arr = self._interleave(dtype=dtype, na_value=na_value)

File D:\anaconda3\Lib\site-packages\pandas\core\internals\managers.py:1794 in _interleave
result[rl.indexer] = arr

ValueError: could not convert string to float: 'F'

@Secbone
Copy link
Member

Secbone commented Dec 10, 2023

@hailee8899 @Aryooo @AnnaYang2223 I think its same to #133 , the issue with pandas >=2.0.x, please upgrade toad to 0.1.3 and have a try. 😄

@AnnaYang2223
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants