I have created a dictionary which has data like this:
0 = {'Input_file': 'Sample_ Data.xlsx', 'Column_Name': 'Status', 'Column_Filter': 'Active'}
1 = {'Input_file': 'Sample_ Data.xlsx', 'Column_Name': 'Status', 'Column_Filter': 'Inactive'}
how can I iterate through only the values in the same order as 0 and 1 without the keys getting printed. I want to read :- Sample_Data.xlsx , Status, Active
in the first iteration and Sample_Data.xlsx , Status, Inactive
in the second.
Below is the code I am using to print.
my_dict = reference.to_dict('index')
for column,values in my_dict.items():
print("{} = {}".format(column, values))
You can use list(dict.keys())
to get the keys as a list. As N_tro_P pointed out, you can use sorted(dict.keys())
to get keys in sorted order and iterate with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With