Modified code to target two slices of sales_data_2021 np array

This commit is contained in:
Donald Calloway 2025-09-29 09:44:13 -07:00
parent b60013e216
commit d8adc75a00

View File

@ -13,6 +13,7 @@ sales_data_2021 = np.array([[350, 420, 380, 410], [270, 320, 290, 310]])
# Create a copy of sales_data_2021
sales_data_2022 = np.copy(sales_data_2021)
# Assign the NumPy array with elements 390 and 370 to the correct slice
sales_data_2022[0, -2:] = np.array([390, 370])
sales_data_2022[0, -2:] = np.array([360, 420]) # Modify 1st element, Q3 & Q4
sales_data_2022[1, :2] = np.array([280, 330]) # Modify 2nd element, Q1 & Q2
print(f'Quarterly sales in 2021:\n{sales_data_2021}')
print(f'Quarterly sales in 2022:\n{sales_data_2022}')
print(f'Quarterly revised sales in 2022:\n{sales_data_2022}')