I've got a pretty simple case that, for some reason, is giving me problems.
I'm combining multiple dataframes. As a result, I'll often have the same key, but different comments for each key value.
KeyValue Comment
1235 This is okay
444 Problems here
1235 Investigate further
I'm trying to deduplicate the keys but preserve all of the comments by consolidating them into one Comments field. The output I'd like:
KeyValue Comment
1235 This is okay | Investigate further
444 Problems here
I've tried:
newdf = olddf.groupby('KeyValue')['Comment'].apply(lambda x: ' | '.join(x)).reset_index()
But when I do that I get
"TypeError: sequence item 0: expected str instance, float found"
I've seen similar questions to mine on here (that's where I got the original code) but not sure why I'm getting this error or how to resolve it. Any help would be appreciated.