I have a Pandas dataframe(df) with following columns:
df["ids"]
0 18281483,1658391547
1 1268212,128064430
2 1346542425
3 13591493,13123669,35938208
df["id"]
0 18281483
1 1268212
2 1346542425
3 13123669
I like to find out, in which order of "ids" the respective "id" can be found, and output the respective value in a new column "order". Following code was tried without success:
df["order"] = df["ids"].str.split(",").index(df["id"])
----------------------------------------------------------------------
TypeError: 'Int64Index' object is not callable
Is there a syntax error? I tried the split and index function with every row manually (by inserting the lists and string), and it worked.
Desired output:
df["order"]
0 0
1 0
2 0
3 1