说我有这个数据框:
example4
RESULT系列具有数据类型列表。我希望能够过滤其中具有 A 的SN,因此我的输出应为 100,103 。我尝试过:
$foo-please_interpolate_me-$bar
甚至:
SN RESULT
1 100 [A]
2 101 [B]
3 103 [A, B]
4 104 [B]
作为我的病情,但我只得到一个错误,因为它认为我正在尝试将整个系列与一个列表进行比较。
ValueError:长度必须匹配才能进行比较
我敢肯定,有一种方法可以不将RESULTS系列转换为字符串。有想法吗?
答案 0 :(得分:4)
private subject : Subject<number> = new Subject<number>();
observable$: Observable<number> = this.subject.asObservable();
value: number = 0;
constructor() { }
ngOnInit() {
this.value = 10;
this.observable$
.subscribe(this.handleData, this.handleError, this.handleComplete);
this.subject.next(12);
this.subject.next(15);
//this.subject.complete();
this.subject.next(16);
}
def update(to_update, key, val):
for k, v in to_update.items():
if k == key:
to_update[k] = val
else:
if isinstance(v, dict):
update(v, key, val)
elif isinstance(v, list):
for item in v:
if isinstance(item, (dict, list)):
update(item, key, val)
else:
continue
else:
continue
return to_update
for id_ in id_list:
new = update(temp, 'id', id_)
print(new)
{'ent': {'type': 'IDN', 'attributes': [{'ent': {'id': 'asf245'}}], 'limit': 20}}
{'ent': {'type': 'IDN', 'attributes': [{'ent': {'id': 'kjb456'}}], 'limit': 20}}
{'ent': {'type': 'IDN', 'attributes': [{'ent': {'id': '235sdg'}}], 'limit': 20}}
逻辑export { Analytics as Analytics };
// Goddamn scroll-to links
// Get offset height depending on our sweet ass screen width
if (window.innerWidth < 768) {
var theOffset = 16;
} else if ( $(this).is(':first')) {
//var offset = $('.entry-header').height() + 30;
} else {
var theOffset = $('.subheader').height() + 30;
}
$('a[href*=#]:not([href=#])').click(function() {
//$('.subheader li').removeClass('active');
//$(this).closest('li').addClass('active');
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: (target.offset().top - theOffset)
}, 500);
return false;
}
}
});
and this:
if(window.location.hash) {
$('html,body').animate({
scrollTop: $(window.location.hash).offset().top-theOffset
}, 900, 'swing');
}
df[['A' in x for x in df.RESULT]]
SN RESULT
1 100 [A]
3 103 [A, B]
答案 1 :(得分:4)
另一个:apply()
一个str连接并通过series.str.contains()
搜索:
df[df.RESULT.apply(''.join).str.contains('A')]
或者不适用:
df[df.RESULT.str.join('').str.contains('A')] #thanks QuangHoang
SN RESULT
1 100 [A]
3 103 [A, B]
答案 2 :(得分:3)
怎么样
df[pd.DataFrame(df.RESULT.tolist()).eq('A').any(1).values]