E.g.
df = DataFrame({"a": [1, 1, 2, 2], "b": range(4)})
gb = df.groupby("a", as_index=False)
result = gb.corrwith(df, numeric_only=False)
print(result)
# b a
# 0 1.0 NaN
# 1 1.0 NaN
result = gb.corrwith(df.rename(columns={"a": "a_"}), numeric_only=False)
print(result)
# a b a_
# 0 1 1.0 NaN
# 1 2 1.0 NaN
When the DataFrame passed to corrwith
has a column with the same name as an in-axis grouper, the grouper does not make it to the result.
One possible expected result would be to insert the in-axis grouper as a column with the same name, but this would give rise to duplicate column names which can be difficult to deal with.
Comment From: ramvikrams
i'll take this up
Comment From: ramvikrams
actually could you guide me, I tried a lot but could not get to a solution
Comment From: rhshadrach
@ramvikrams - I'm not sure what a good resolution here would be. See the last sentence of the OP.
Comment From: ramvikrams
@ramvikrams - I'm not sure what a good resolution here would be. See the last sentence of the OP.
could you please tell what is OP here is it opcodes
Comment From: rhshadrach
Opening post - the very first comment.
Comment From: ramvikrams
Opening post - the very first comment.
Thanks, I'll look into it.
Comment From: ramvikrams
@rhshadrach , could you only take it up I tried but could not do it.