Given the following:
dd = {}
for i in range(3):
for j in range(3):
key = (f"col_{i}", j)
dd[key] = {1: 2, 3: 4}
print(pd.DataFrame.from_dict(dd))
Which looks as:
col_0 col_1 col_2
0 1 2 0 1 2 0 1 2
1 2 2 2 2 2 2 2 2 2
3 4 4 4 4 4 4 4 4 4
I would like to use the following replacements:
reps = {
"col_0": {0: "o", 1: "one", 2: "two"},
"col_1": {0: "o2", 1: "one2", 2: "two2"},
"col_2": {0: "o3", 1: "one3", 2: "two3"},
}
So that the col_0, col_1, col_2 are unchanged, but the second level of
0,1,2 is changed to o, one, two, o2, one2, two2, and o3, one, two3
respectively , giving something similar to :
col_0 col_1 col_2
o one two o2 one2 two2 o3 one3 two3
1 2 2 2 2 2 2 2 2 2
3 4 4 4 4 4 4 4 4 4