【发布时间】:2017-07-24 22:34:13
【问题描述】:
我创建了两个表并试图合并它们,但由于某种原因它不起作用。
我的两张表是:
table_account_id = data1.groupby('employer_key').account_id.nunique() #how many people logged in (unique account id)
table_eligible = data3.groupby(['employer_key'])[['eligible']].sum().astype('int') #eligible population
我希望我的新表具有以下列:
Employer_key // account_id // eligible
我认为代码如下,但它不起作用:
new_table = pd.merge(table_eligible, table_account_id, left_index=True, right_index=True)
在我将 nunique 函数插入到我的 table_account_id 代码之前,我能够合并这两个表。
谢谢!
【问题讨论】:
-
您能否将您的 DataFrames 添加到您的问题(或一些具有代表性的示例数据)中,并详细说明什么“不起作用”?