如果我有这个字符串列表:
['fsuy3,fsddj4,fsdg3,hfdh6,gfdgd6,gfdf5',
'fsuy3,fsuy3,fdfs4,sdgsdj4,fhfh4,sds22,hhgj6,xfsd4a,asr3']
Run Code Online (Sandbox Code Playgroud)
(大名单)
如何删除少于1%和超过60%字符串的所有单词?
我是mysql的新手,我需要一些帮助.我想从存在值的表中选择所有行,但不选择该值:
例如:
ID ITEM
--------------------
1 AA
1 22S
1 AB
2 F45
2 BB
3 1
3 1
3 AA
3 F45
3 F67
3 A
......
Run Code Online (Sandbox Code Playgroud)
类似于:SELECT ID,ITEM FROM TABLE1如果项目"AA"除了"AA"之外,它将返回:
1 225,AB
3 1,1,F45,F67,A
Run Code Online (Sandbox Code Playgroud)
这样做的实际查询是什么?谢谢
好的,我可能做错了什么,但是按照用户的建议,我运行这个查询:
SELECT id, item,
(SELECT COUNT(item) FROM Table1 WHERE id=a.id AND item=a.item) cnt
FROM (SELECT DISTINCT a.id,b.item FROM Table1 a, Table1 b) a
ORDER BY id, item;
Run Code Online (Sandbox Code Playgroud)
在这张桌子上:
ID ITEM
-----------------
0001 345
0001 345
0001 120
0002 567
0002 034
0002 567
0003 567
0004 533
0004 008
...
Run Code Online (Sandbox Code Playgroud)
为了得到这个结果:
ID ITEM CNT
1 8 0
1 34 0
1 120 1
1 345 2
1 533 0
1 567 0
2 8 0
2 34 1
...
Run Code Online (Sandbox Code Playgroud)
但它花了太长时间,一天后查询仍在运行......有没有办法提高性能?我有大约400万行 …
我在Python中有这个列表列表:
[[100,XHS,0],
[100,34B,3],
[100,42F,1],
[101,XHS,2],
[101,34B,5],
[101,42F,2],
[102,XHS,1],
[102,34B,2],
[102,42F,0],
[103,XHS,0],
[103,34B,4],
[103,42F,2]]
Run Code Online (Sandbox Code Playgroud)
我想找到最有效的方法(我正在处理大量数据)使用每个id(第一个元素)的每个列表中的最后一个元素创建一个新的列表列表.所以对于样本列表上面,我的结果是:
[[0,3,1],
[2,5,2],
[1,2,0],
[0,4,2]]
Run Code Online (Sandbox Code Playgroud)
我怎样才能在Python中实现它?谢谢
我有这个清单:
[0,0,3,3,0,1,1,1,3,3,0,2,0,2,0,0,2,2]
Run Code Online (Sandbox Code Playgroud)
这个清单:
[18,23,56,34,23,67,89,43,12,22,34,21,54,23,67,12,45,67]
Run Code Online (Sandbox Code Playgroud)
(它们的长度是相同的)..我想找到一种方法从这些列表生成一个字典,使用dict的键作为第一个列表中的值,并作为每个键的值,第二个列表的数字对应第一个清单的位置..
结果将是:
dict = {'0': '18,23,23,34,54,67,12', '1':'67,89,43',.........}
Run Code Online (Sandbox Code Playgroud)
我该如何实现这一点..非常感谢
这是我正在运行的查询(28小时过去了!):
drop table if exists temp_codes;
create temporary table temp_codes
select distinct CODE from Table1;
alter table temp_codes
add primary key (CODE);
drop table if exists temp_ids;
create temporary table temp_ids
select distinct ID from Table1;
alter table temp_ids
add primary key (ID);
drop table if exists temp_ids_codes;
create temporary table temp_ids_codes
select ID, CODE
from temp_ids, temp_codes;
alter table temp_ids_codes
add index idx_id(ID),
add index idx_code(CODE);
insert into Table2(ID,CODE,cnt)
select
a.ID, a.CODE, coalesce(count(t1.ID), 0)
from
temp_ids_codes as a
left …Run Code Online (Sandbox Code Playgroud) 如何计算单词出现在字符串列表中的次数?
例如:
['This is a sentence', 'This is another sentence']
Run Code Online (Sandbox Code Playgroud)
而且"句子"这个词的结果是2