I have a dataset
ID col1 col2 year
1 A 111,222,3334 2010
2 B 344, 111 2010
3 C 121,123 2011
I wanna rearrange the dataset in the following way
ID col1 col2 year
1 A 111 2010
1 A 222 2010
1 A 3334 2010
2 B 344 2010
2 B 111 2010
3 C 121 2011
3 C 123 2011
I can do it using the following code.
a = df.COMP_MONITOR_TYPE_CODE.str[:3]
df['col2'] = np.where(a == 111, 111)
Since, I have a very long data, its would be time consuming to do it one by one. Is there any other way to do it