Aggregating in 2-D Arrays
All the aggregate functions learned in this section can be used along either columns, or rows. To do it, you need to specify the axis parameter within aggregate function.
For example, we can compute the sum of rows and columns elements separately.
1234567# Import the library import numpy as np # Creating array arr = np.array([[5.2, 3.0, 4.5], [9.1, 0.1, 0.3]]) # Sum of rows and columns elements print(arr.sum(axis = 0)) # columns print(arr.sum(axis = 1)) # rows
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 6
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Ask me questions about this topic
Summarize this chapter
Show real-world examples
Awesome!
Completion rate improved to 2.7
Aggregating in 2-D Arrays
Swipe to show menu
All the aggregate functions learned in this section can be used along either columns, or rows. To do it, you need to specify the axis parameter within aggregate function.
For example, we can compute the sum of rows and columns elements separately.
1234567# Import the library import numpy as np # Creating array arr = np.array([[5.2, 3.0, 4.5], [9.1, 0.1, 0.3]]) # Sum of rows and columns elements print(arr.sum(axis = 0)) # columns print(arr.sum(axis = 1)) # rows
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 6