【发布时间】:2023-03-20 03:21:01
【问题描述】:
我加入了多个 DataFrame,现在我只有一个 DataFrame。现在我想为没有冗余的列创建相同的 ID 行。说清楚:
我现在拥有的 DataFrame:
column1 column2 column3
row1 2 4 8
row2 1 18 7
row3 54 24 69
row3 54 24 10
row4 26 32 8
row4 26 28 8
你可以看到我有两个 row3 和 row4 但它们在 column2 和 column3 中是不同的
这是我想要得到的DataFrame:
column1 column2 column3 row3_a row4_a
row1 2 4 8 NULL NUll
row2 1 18 7 NULL NULL
row3 54 24 69 10 NULL
row4 26 28 8 NULL 28
任何想法我应该如何解决这个问题?
【问题讨论】:
-
你能提供数据作为数据框构造函数吗?
-
是的,我可以而且我已经做到了
-
这不是 DataFrame 构造函数 (
df = pd.DataFrame(...)) ;) -
那我应该使用哪个构造函数?