首页 > 解决方案 > I got an error in appending a dataframe row from one to another dataframe

问题描述

frontbar1_v_elements, frontbar1_h_elements, rearbar_elements, sidebar_up_elements, sidebar_down_elements are the lists. draft_indep is a dataframe with only one row and multiple columns, all cell attended as zero. total1 is a 2D list. The code is dedicated to change "1" to some certain "0" in a1 according to total1. It works well to until this line. But the row in a1 could not be appended to main_indep which is a dataframe. By the way, a1 was deep copied from draft_indep and draft_indep deep copied from main_indep.

total1=[frontbar1_v_elements,frontbar1_h_elements,rearbar_elements,sidebar_up_elements,sidebar_down_elements]
a1=draft_indep.copy()
for single in total1:
   for ele in single:
       a1.at[0,ele]=int(1)
        
main_indep.append(a1, ignore_index=True) 

标签: pythonarrayspandaslistdataframe

解决方案


推荐阅读