I am trying to simply merge one dataframe to another, but keep getting an unexpected output
My dataframes are:
grouped.head()
which ouputs:
Lifetime_Revenue Customer_ID Lifetime
Cohort
----------------------------------------------
2014-01 149.90 1 NaN
2014-02 299.90 1 NaN
2014-03 1499.68 3 NaN
2014-04 299.90 1 NaN
2014-05 2249.70 3 NaN
the other is:
Lifetime
---------
0 10
1 10
2 11
3 9
4 12
I am trying to merge Lifetime from ltnew to grouped but when I try to merge the two:
merged = pd.merge(grouped,ltnew,on=['Lifetime'],right_index=True)
The output is just a flattened dataframe:
Lifetime_Revenue Customer_ID Lifetime
Cohort
------------------------------------------------
Doing an outer and left join just reproduces an exact copy of the grouped dataframe, while doing a right just fills in the lifetime column but leaves all other columns null.
Anyone able to help?