Two Tools Form the Floor of Analysis
To visualize and preprocess, NumPy and Pandas have to be second nature. I built the basics by solving many problems.
NumPy — The Array Mindset
I repeated the essentials across 100 problems.
import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
print(a.ndim, a.shape) # dimensions and shape- Created and reshaped arrays with
arange,linspace,reshape,flatten - Used slicing to select rows/columns, the last element, and the first N
- Learned the broadcasting rules for operating on differently shaped arrays
- Handled conditions and joins with
where,sort,concatenate,transpose - Confirmed the dtype rule that
np.array(['1', 2, '3'])unifies everything to strings
Pandas — A Language for Tables
countries = pd.DataFrame(data).set_index("country")
countries[countries["density"] > 300][["capital", "population"]]- Created derived columns such as
density = population / area - Extracted countries with density between 100 and 300 by conditional filtering
- Searched capital names with the string methods
str.len()andstr.contains("am") - Practiced editing values and indexing, and aggregated and explored movie-review data
Takeaway
Key point
NumPy gave me the mindset of numeric arrays, and Pandas gave me a language for questioning tables. The knack of turning "which capitals have density over 300?" into a single line became the floor for all my later analysis and modeling.