0
0
SciPydata~5 mins

CSC format (Compressed Sparse Column) in SciPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does CSC stand for in sparse matrix storage?
CSC stands for Compressed Sparse Column. It is a way to store sparse matrices efficiently by compressing data column-wise.
Click to reveal answer
intermediate
How does CSC format store the matrix data?
CSC stores three arrays: one for non-zero values, one for row indices of those values, and one for column pointers that mark where each column starts in the values array.
Click to reveal answer
beginner
Why is CSC format useful in data science?
CSC format saves memory and speeds up column-based operations like matrix-vector multiplication, which is common in data science tasks.
Click to reveal answer
beginner
Show a simple example of creating a CSC matrix using scipy.
You can create a CSC matrix with scipy.sparse.csc_matrix. For example:<br><pre>from scipy.sparse import csc_matrix
import numpy as np

# Create a dense matrix
dense = np.array([[0, 0, 1], [1, 0, 0], [0, 2, 0]])

# Convert to CSC format
csc = csc_matrix(dense)
print(csc)</pre>
Click to reveal answer
intermediate
What is the difference between CSC and CSR formats?
CSC compresses columns and is efficient for column slicing and operations. CSR (Compressed Sparse Row) compresses rows and is better for row slicing and row-based operations.
Click to reveal answer
What does the 'indptr' array in CSC format represent?
AValues of non-zero elements
BColumn pointers marking start of each column in data array
CRow indices of non-zero elements
DTotal number of non-zero elements
Which operation is CSC format especially efficient for?
ARow slicing and row-based matrix operations
BDense matrix multiplication
CColumn slicing and column-based matrix operations
DSorting matrix elements
In scipy, which function creates a CSC sparse matrix?
Ascipy.sparse.lil_matrix()
Bscipy.sparse.csr_matrix()
Cscipy.sparse.dok_matrix()
Dscipy.sparse.csc_matrix()
What is stored in the 'data' array of a CSC matrix?
ANon-zero values of the matrix
BRow indices of non-zero values
CColumn pointers
DZero values
Which format is better for fast row slicing?
ACSR (Compressed Sparse Row)
BCSC (Compressed Sparse Column)
CDense matrix
DDiagonal matrix
Explain how the CSC format stores a sparse matrix and why it is useful.
Think about how columns are compressed and what arrays are needed.
You got /6 concepts.
    Describe the difference between CSC and CSR formats and when to use each.
    Focus on which dimension is compressed and the typical operations.
    You got /5 concepts.