[英]How to append column of one data frame as row of another data frame based on row/column name?
I have 2 data frames, df1:我有 2 个数据框,df1:
x1 x2 x3 x4 x5
y1
y2
y3
y4
y5
and df2:和 df2:
y1 y2 y3 y4 y5
z1
z2
z3
z4
z5
I want to append the values of df1 as a row in df2 by comparing the row/column names in the dataframes.我想通过比较数据帧中的行/列名称,将 df1 的值作为 df2 中的一行附加。 I did this using Numpy but I want to do this using Pandas.我使用 Numpy 做到了这一点,但我想使用 Pandas 做到这一点。 Kindly help.请帮忙。
can you just create a transponse of df2 and then append/merge/"add" to df1?你能创建一个 df2 的转发,然后附加/合并/“添加”到 df1 吗?
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.transpose.html https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.transpose.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.