NumPy Introduction
๐ง NumPy Introduction
NumPy stands for Numerical Python and is a popular open-source Python library used for:
โ Scientific Computing
โ Working with arrays
โ Mathematical operations
โ Data analysis
โ Machine learning and AI
โ Linear algebra & Fourier transform
โ Working with large datasets efficiently
NumPy is the foundation of libraries like Pandas, SciPy, TensorFlow, and Scikit-Learn.
๐ฅ Why NumPy?
Pythonโs built-in lists are slow and inefficient for numeric processing. NumPy solves this by offering:
| Feature | Python List | NumPy Array |
|---|---|---|
| Speed | โ Slow | โ Very Fast |
| Memory Usage | โ High | โ Low |
| Supports Vectorized Operations | โ No | โ Yes |
| Suitable for ML/Data Science | โ No | โ Yes |
๐ฆ Installing NumPy
If not installed, use:
Or for Anaconda users:
๐งฉ Importing NumPy
Standard practice:
๐ NumPy Array
NumPy works with a special data type called ndarray (n-dimensional array).
๐ Creating an array:
Output:
๐ฏ Multidimensional Array
Output:
๐ Array Properties
โ Creating Special Arrays
๐ฅ Fast Vectorized Operations
โ Mathematical Functions
๐ Array Indexing & Slicing
๐งฎ Reshaping Arrays
๐ Conclusion
NumPy is a powerful and essential library for:
-
Data Science
-
Machine Learning
-
Deep Learning
-
Scientific and mathematical calculations
It makes handling numeric data faster, easier, and more memory-efficient.
