我有2列,我们将其称为x和y。我想创建一个名为xy
的新列kubectl apply
不应有任何冲突的值,但如果存在,则y优先。如果使解决方案更容易,则可以假定x始终为NaN,其中y具有值。
答案 0 :(得分:2)
请注意,您现在的列类型不再是数字字符串
cron:
- description: "make some select/insert"
url: /tasks/populate
schedule: every 1 mins
target: populate_postgres
更多
df = df.apply(lambda x : pd.to_numeric(x, errors='coerce'))
df['xy'] = df.sum(1)
答案 1 :(得分:1)
如果您的示例正确,可能会很简单
df.fillna(0) #if the blanks are nan will need this line first
df['xy']=df['x']+df['y']
答案 2 :(得分:0)
您还可以使用NumPy:
static createMarkup(container, transition = false) {
let wrapper = document.createElement('div');
wrapper.classList.add('slides-flow__wrap');
if (transition) wrapper.style.transition = `transform ${transition}`;
const slides = Array.from(container.children);
let appendSlides = [];
while(slides.length > 0) {
appendSlides.push(slides.splice(0,3))
}
let wrappedSlides = appendSlides.map(slide => {
let slideWrap = document.createElement('div');
slideWrap.classList.add('slides-flow__slide');
slide.forEach(el => slideWrap.appendChild(el));
return slideWrap;
});
wrappedSlides.forEach(wrappedSlide => {
wrapper.appendChild(wrappedSlide);
});
container.appendChild(wrapper);
return {
container,
wrapper,
slides: wrappedSlides
}
}