Background Information
This question is closely related to my previous question. Unfortunately while making up an general example it was not specific enough to be applied to my personal problem. That is why this question is more specific.
Example - Code Snippet
import pandas as pd
import numpy as np
inp = [{'ID_Code':1,'information 1':[10,22,44],'information 2':[1,0,1]},
{'ID_Code':2,'information 1':[400,323],'information 2':[1,1]},
{'ID_Code':2,'information 1':[243],'information 2':[0]},
{'ID_Code':2,'information 1':[333,555],'information 2':[0]},
{'ID_Code':3,'information 1':[12,27,43,54],'information 2':[1,0,1,1]},
{'ID_Code':3,'information 1':[31,42,13,14],'information 2':[1,0,0,0]},
{'ID_Code':3,'information 1':[14,24,34,14],'information 2':[1,0,1,1]},
{'ID_Code':4,'information 1':[15,25,33,44],'information 2':[0,0,0,1]},
{'ID_Code':5,'information 1':[12,12,13,14],'information 2':[1,1,1,0]},
{'ID_Code':5,'information 1':[12,12,13,24],'information 2':[1,0,1,1]},
{'ID_Code':5,'information 1':[21,22,23,14],'information 2':[1,1,1,1]},
{'ID_Code':6,'information 1':[10,12,23,4],'information 2':[1,0,1,0]},
{'ID_Code':7,'information 1':[112,212,143,124],'information 2':[0,0,0,0]},
{'ID_Code':7,'information 1':[211,321],'information 2':[1]},
{'ID_Code':7,'information 1':[431],'information 2':[1,0]},
{'ID_Code':8,'information 1':[1,2,3,4],'information 2':[1,0,0,1]}]
df = pd.DataFrame(inp)
df1=df.groupby("ID_Code")["information 1"].apply(list).to_frame()
df2=df.groupby("ID_Code")["information 2"].apply(list).to_frame()
df3=pd.concat([df1, df2],axis=1, sort=False)
The Output
ID_Code information 1 information 2
1 [[10, 22, 44]] [[1, 0, 1]]
2 [[400, 323], [243], [333, 555]] [[1, 1], [0], [0]]
3 [[12, 27, 43, 54], [31, 42, 13, 14], [14, 24, 34, 14]] [[1, 0, 1, 1], [1, 0, 0, 0], [1, 0, 1, 1]]
4 [[15, 25, 33, 44]] [[0, 0, 0, 1]]
5 [[12, 12, 13, 14], [12, 12, 13, 24], [21, 22, 23, 14]] [[1, 1, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1]]
6 [[10, 12, 23, 4]] [[1, 0, 1, 0]]
7 [[112, 212, 143, 124], [211, 321], [431]] [[0, 0, 0, 0], [1], [1, 0]]
8 [[1, 2, 3, 4]] [[1, 0, 0, 1]]
Where ID_Code is no longer a column but the index. Which is the problem that I hadn't specified in my previous question.
The Task
With the given Dataframe "df3", to get rid of ID_Code = 1 and store its information in ID_Code = 3, and get rid of ID_Code = 5 and ID_Code = 7 and store that information in ID_Code = 2, so that the DataFrame looks like this:
ID_Code information 1 information 2
2 [[400, 323], [243], [333, 555], [12, 12, 13, 14], [12, 12, 13, 24], [21, 22, 23, 14], [112, 212, 143, 124], [211, 321], [431]] [[1, 1], [0], [0], [1, 1, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [0, 0, 0, 0], [1], [1, 0]]
3 [[12, 27, 43, 54], [31, 42, 13, 14], [14, 24, 34, 14], [10, 22, 44]] [[1, 0, 1, 1], [1, 0, 0, 0], [1, 0, 1, 1], [1, 0, 1]]
4 [[15, 25, 33, 44]] [[0, 0, 0, 1]]
6 [[10, 12, 23, 4]] [[1, 0, 1, 0]]
8 [[1, 2, 3, 4]] [[1, 0, 0, 1]]
It would be a huge help, if someone could help me solve this.