def remove_rows(dic,row_list):
new=[]
column=[]
for key,value in dic.items():
column.append(key)
for k,v in value.items():
if k not in row_list and k not in new:
new.append(k)
final={}
for col in column:
for index in new:
print(dic[col][index])
my task was to create a function that returns a new dictionary without the rows that have their index specified in the row_list /second augment in the function created.
Nb. I don’t understand the clean method used as the answer. hence the reason why I attempted to create my own from scratch. I dislike this method because it doesnt give me a chance to appreciate what is going on behind the scene
For my function created above, I got stuck. I have managed to print out the values associated to the indices not in row_list. but how to relate what I have managed to achieve back to the format {column_name: {index: value}} to create a new dictionary which I could return is were am stucked at.
any help to enable me finish up my code and understand the clean and shorter method used in the solution provided is welcomed