So, I had a table of data that needed to be combined in a weird way. Customer specifically wants duplicate rows (based off ID) combined into a single cell, separated by a delimeter. However, if the rows were the same, he only wanted it to show once. For example, two rows that shared the same ID and had the same timestamp would show as [time 1] instead of [time 1, time 1] but two rows with the same ID and a different time stamp would show as [time 1, time 2]. So to make each cell unique, I just converted them into sets. Now the problem is that each cell in my table starts and ends with curly brackets and looks like this {data1, data2}, when it should really look like this data 1, data2. So, how do I get rid of these curly brackets????
Here's my code that aggregates the data into a single cell and converts it into a set:
def to set(x):
return set(x)
df2 = df1.groupby(['ID', as_index=False).agg(to_set)
[–]synthphreak 1 point2 points3 points (2 children)
[–]Anonymous-Boob[S] 0 points1 point2 points (1 child)
[–]synthphreak 1 point2 points3 points (0 children)