鉴于两个系列s1
和s2
,这两个代码片段是否等效?
s1, _ = s1.align(s2, join='right')
和
for k in s2.index:
if not k in s1.index:
s1[k] = np.nan
答案 0 :(得分:1)
是的,2个代码是等效的,但如果s2
大于s1
,则与for
循环的第二个选项相比第一个align
慢var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 2000); // Change image every 2 seconds
}
}