Here is the code I used to calculate average with numpy and pandas
def calc_average_books_stock():
text_file = open('book_data_file.txt')
values = []
for index,data in df.iterrows():
if int(data['STOCK']) > 0:
values.append(data['COST?'])
avg = np.mean(values)
print(f"Average Book in Stock: {round(avg, 2)}")
I would like to know if there was a way to this without numpy and pandas and just be able to do it with python's standard library