![](/img/trans.png)
[英]Get columns names from one data frame and add them as empty columns in another data frame in pandas
[英]pandas: Add row from one data frame to another data frame?
我有兩個具有相同列標題的數據幀。
我正在迭代df1中的行,拆分其中一列,然后使用這些拆分列創建多行以添加到另一個數據幀。
for index, row in df1.iterrows():
curr_awards = row['AWARD'].split(" ")
for award in curr_awards:
new_line = row
new_line['AWARD'] = award.strip()
#insert code here to add new_line to df2
將行添加到另一個數據框的pandas方法是什么?
我想到了。
for index, row in df1.iterrows():
curr_awards = row['AWARD'].split(" ")
for award in curr_awards:
new_line = row
new_line['AWARD'] = award.strip()
df2.loc[len(df2)] = new_line
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.