1.
NumPy Reshape:
reshape() changes array shape.
-1 lets NumPy infer dimension.
Example: [Link](arr, (2, -1)) auto-fits the second dimension.
2. iloc vs loc:
.loc: label-based indexing.
.iloc: integer position-based.
Example: [Link][0] vs [Link][0]
3. Installing Libraries:
- pip: Python packages (pip install numpy)
- conda: Manages environments and packages (conda install numpy)
- manual: Download and install manually
pip: fast, broad support
conda: good for data science, dependencies
manual: advanced, flexible
4. Series vs DataFrame:
Series: 1D labeled array
DataFrame: 2D labeled table
5. Array Shape Manipulation:
- Transpose: arr.T
- Reshape: [Link]((2,3))
- Stack: [Link](), [Link]()
- Split: [Link](arr, 2)
6. Import CSV in Pandas:
pd.read_csv("[Link]", na_values="NA", dtype={'col': int})
Parameters: delimiter, header, index_col, na_values, dtype
7. NumPy Slicing:
arr = [Link]([1, 2, 3, 4])
print(arr[1:3]) # [2 3]
8. Import CSV:
pd.read_csv("[Link]")
[Link].from_csv("[Link]") # Deprecated
9. SciPy is used for differential equations
10. Matplotlib Plot:
[Link](x, y)
[Link]()
11. Create Arrays:
- [Link]([1, 2, 3])
- [Link](5)
- [Link]((2,2))
- dtype: defines data type like int32, float64
12. Series Attributes:
s = [Link]([1, 2, 3])
[Link], [Link], [Link]
13. NumPy + Pandas:
NumPy handles arrays, Pandas structures data.
Example: Use NumPy for math, Pandas for table ops.
14. Math Ops on Series:
[Link](), [Link](), [Link]()
NaN ignored by default.
15. Concatenate Arrays:
[Link]((a, b), axis=0)
Mismatch shape -> error
16. Series vs DataFrame:
Series: single column
DataFrame: multi-column table
17. Create DataFrame:
- From dict: [Link]({'A': [1, 2]})
Attributes: .shape, .columns, .index
18. Series Indexing:
[Link]([2, 1, 0])
[Link](other_series)
19. NumPy vs Python Stats:
Python: slow loop
NumPy: fast vector ops
Example:
[Link](arr) vs sum(arr)/len(arr)
20. Data Selection in Pandas:
.loc[label], .iloc[pos], .at[label], .iat[pos]