You can replace the data load as follows
you can probably also iterate the plot in a similar fashion
import matplotlib.pyplot as plt
import pandas as pd
tester = {}
file = 'E:/Document/python/Book1.xlsx'
df = pd.read_excel(file)
for name in df.columns:
if name.startswith('Data'):
new_colname = f"{name}_tester{name[4:]}"
tester[name] = df.filter(items=[name])
# How to use:
print(tester.keys())
print(f"\n{tester['Data1']}")
print(f"\n{tester['Data2']}")
# ax1 = plt.subplot(2,1,1)
# ax1.boxplot([data1_tester1,data1_tester2,data1_tester3,data1_tester4,data1_tester5])
# ax1.set_xticklabels('')
# ax2 = plt.subplot(2,1,2)
# ax2.boxplot([data2_tester1,data2_tester2,data2_tester3,data2_tester4,data2_tester5],labels=['Tester 1','Tester 2','Tester 3','Tester 4','Tester 5'])
# plt.show()
output of printf statements above:
Output:
dict_keys(['Data1', 'Data2', 'Data3', 'Data4', 'Data5', 'Data6', 'Data7', 'Data8', 'Data9', 'Data10'])
Data1
0 6.91
1 5.79
2 7.12
3 7.61
4 7.70
.. ...
94 7.92
95 6.66
96 7.07
97 5.64
98 7.18
[99 rows x 1 columns]
Data2
0 20.96
1 18.78
2 21.05
3 21.96
4 20.47
.. ...
94 19.92
95 21.09
96 20.94
97 18.86
98 18.41
[99 rows x 1 columns]