I have a dataframe as such
ID NAME group_id
0 205292 A 183144058824253894513539088231878865676
1 475121 B 183144058824253894513539088231878865676
1 475129 C 183144058824253894513539088231878865676
I want to transform it such that row 0 is linked to the other rows in the following way
LinkedBy By_Id LinkedTo To_Id group_id
1 A 205292 B 475121 183144058824253894513539088231878865676
2 A 205292 C 475129 183144058824253894513539088231878865676
Basically, I am compressing the first dataframe by linking 0th index row against all other such that an n row df will give me a (n-1) row df. I can accomplish this without the group id (which is of type long and stays constant) by the following code:
pd.DataFrame({"LinkedBy": df['NAME'].iloc[0],"By_Id": df['ID'].iloc[0],"LinkedTo":df['NAME'].iloc[1:],"To_Id":df['ID'].iloc[1:]})
But I am facing problems while adding a group id. When I do the following
pd.DataFrame({"LinkedBy": df['NAME'].iloc[0],"By_Id": df['ID'].iloc[0],"LinkedTo":df['NAME'].iloc[1:],"To_Id":df['ID'].iloc[1:],"GroupId":df['potential_group_id'].iloc[0]})
I get OverflowError: long too big to convert
How do I add the group_id of type long to my new df.


strinstead which should work? so basically cast the dtype using.astype(str)"LinkedBy": df['NAME'].iloc[0]this has only one entry but"LinkedTo": df['NAME'].iloc[1:]this one has two. Instead of[A]you need to pass[A, A]. Maybe with2* [df['NAME'].iloc[0]].