Podcast
Questions and Answers
What does np.arange(7)
return?
What does np.arange(7)
return?
Given arr = np.array([[1, 2, 3], [4, 5, 6]])
, what will arr.sum(axis=0)
output?
Given arr = np.array([[1, 2, 3], [4, 5, 6]])
, what will arr.sum(axis=0)
output?
Which NumPy function will generate a 4x4 matrix with all elements as zeros?
Which NumPy function will generate a 4x4 matrix with all elements as zeros?
What does np.random.randint(1, 10, 3)
do?
What does np.random.randint(1, 10, 3)
do?
Signup and view all the answers
Given a = np.array([1, 2, 3])
and b = np.array([2, 2, 2])
, what will np.dot(a, b)
output?
Given a = np.array([1, 2, 3])
and b = np.array([2, 2, 2])
, what will np.dot(a, b)
output?
Signup and view all the answers
Which method, given an array arr
, can be used to insert a new column at a specific index?
Which method, given an array arr
, can be used to insert a new column at a specific index?
Signup and view all the answers
Given df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
, what does df['B'].sum()
return?
Given df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
, what does df['B'].sum()
return?
Signup and view all the answers
Given a DataFrame df
, how can you select all rows where column 'A' is greater than 2 and column 'B' is less than 5?
Given a DataFrame df
, how can you select all rows where column 'A' is greater than 2 and column 'B' is less than 5?
Signup and view all the answers
Study Notes
NumPy Functions
-
np.arange(5)
returns[0, 1, 2, 3, 4]
-
sum(axis=1)
calculates the row-wise sums in a 2D array
NumPy Identity Matrix
-
np.identity(3)
generates a 3x3 identity matrix
Random Number Generation
-
np.random.random()
generates random numbers between 0 and 1
NumPy Array Operations
-
np.append()
adds a new row to the end of a NumPy array
Pandas DataFrame Operations
-
The
sum()
method on a Pandas Series calculates the sum of the values. -
df.isnull()
checks for missing or NaN values in a DataFrame. -
df.groupby()
groups data based on column values, enabling aggregation and transformation -
df.dropna()
removes rows containing missing values. -
To select rows where 'A' is greater than 2, use
df.loc[df['A'] > 2]
,df.query('A > 2')
, ordf[df['A'] > 2]
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Test your knowledge of NumPy and Pandas functions with this quiz. It covers various aspects like array manipulations, identity matrices, random number generation, and DataFrame operations, including sums, grouping, and missing values. Perfect for students learning data manipulation in Python!