I'm having problems (sort of) with combining duplicate columns. It seems to work on older versions of Pandas/Python (not sure what the culprit is here), but not on the latest version.
I basically have a dataframe of mixed values with duplicate column names after a concat. The values are either going to be a int, string, or nan. All non-nan values are going to be the same for each duplicate column name, so in theory max() should do the trick.
Say I have the Dataframe:
col1 col1 col2 col2 col3
0 Foo nan nan Bar Baz
1 nan nan Bar Bar nan
2 0 nan 1 nan 1
My goal is to get
col1 col2 col3
0 Foo Bar Baz
1 nan Bar nan
2 0 1 1
Doing this
df.groupby(df.columns,axis=1).max()
Does exactly what I want it to do on a older version of Pandas/Python, but does not work for the latest. This is what I'm getting on the latest version:
col1 col2 col3
0 nan nan Baz
1 nan nan nan
2 0 1 1
Any ideas?
maxhere?maxof whatdf.groupby(df.columns, axis=1).first()