An open API service indexing awesome lists of open source software.

https://github.com/emmanuel10701/numpy

Numpy
https://github.com/emmanuel10701/numpy

jupyter-notebook machine-learning numpy pandas python

Last synced: 3 months ago
JSON representation

Numpy

Awesome Lists containing this project

README

          

# NumPy CRUD Operations Walkthrough

This README focuses on demonstrating **CRUD (Create, Read, Update, Delete)** operations in **NumPy** arrays through a Jupyter Notebook. The notebook showcases essential operations for working with numerical data efficiently and converting them into NumPy arrays.

---

## Table of Contents

1. [Introduction](#introduction)
2. [Setup and Dependencies](#setup-and-dependencies)
3. [CRUD Operations in NumPy](#crud-operations-in-numpy)
- [Create Arrays](#create-arrays)
- [Read Arrays](#read-arrays)
- [Update Arrays](#update-arrays)
- [Delete Elements from Arrays](#delete-elements-from-arrays)
4. [Conclusion](#conclusion)

## Introduction

**NumPy** is a powerful library for numerical computing in Python. This walkthrough covers the **CRUD operations** that form the basis of array manipulation and data analysis. CRUD operations help you manipulate data programmatically and are fundamental when working with arrays in data science and scientific computing.

---

## Setup and Dependencies

Make sure you have the following tools and libraries installed on your machine:

- Python 3.x
- Jupyter Notebook or JupyterLab
- NumPy

### Install NumPy

If NumPy is not installed, you can install it using pip:

```bash
pip install numpy
````

You can launch Jupyter Notebook using:

```bash
jupyter notebook
```

---

## CRUD Operations in NumPy

This section demonstrates how to perform **Create**, **Read**, **Update**, and **Delete** operations on NumPy arrays.

### Create Arrays

Use various NumPy functions to create arrays:

```python
import numpy as np

# Create array from list
arr1 = np.array([1, 2, 3])
print("arr1:", arr1)

# Create array of zeros
arr2 = np.zeros((2, 3))
print("arr2:\n", arr2)

# Create array of ones
arr3 = np.ones((3, 2))
print("arr3:\n", arr3)

# Create array with range of numbers
arr4 = np.arange(0, 10, 2)
print("arr4:", arr4)
```

---

### Read Arrays

Access specific elements, rows, or columns from NumPy arrays:

```python
arr = np.array([[10, 20, 30], [40, 50, 60]])

# Read single element
print(arr[0][1]) # Output: 20

# Read entire row
print(arr[1]) # Output: [40 50 60]

# Read specific column
print(arr[:, 2]) # Output: [30 60]

# Slice array
print(arr[0:2, 1:3]) # Output: [[20 30] [50 60]]
```

---

### Update Arrays

Modify the values of arrays using direct indexing:

```python
arr = np.array([5, 10, 15, 20, 25])

# Update single value
arr[2] = 100
print(arr) # Output: [ 5 10 100 20 25]

# Update multiple values
arr[1:4] = [200, 300, 400]
print(arr) # Output: [ 5 200 300 400 25]
```

---

### Delete Elements from Arrays

Use `np.delete()` to remove elements:

```python
arr = np.array([1, 2, 3, 4, 5])

# Delete element at index 2
new_arr = np.delete(arr, 2)
print(new_arr) # Output: [1 2 4 5]

# 2D array example
arr2d = np.array([[1, 2], [3, 4], [5, 6]])

# Delete row 1 (second row)
new_arr2d = np.delete(arr2d, 1, axis=0)
print(new_arr2d) # Output: [[1 2] [5 6]]

# Delete column 0 (first column)
new_arr2d_col = np.delete(arr2d, 0, axis=1)
print(new_arr2d_col) # Output: [[2] [4] [6]]
```

---

## Conclusion

This walkthrough has demonstrated how to perform basic **CRUD operations** with **NumPy**, a core Python library for numerical computation. Mastering these operations is essential for effective data manipulation, analysis, and preprocessing tasks in data science and machine learning workflows.

---

Happy Coding! 🎉

```

### ✅ How to Use:
1. Save this as `README.md` in your project folder.
2. Run the code snippets in a Jupyter Notebook or any Python environment.
3. Add screenshots, visuals, or outputs if desired for a more interactive guide.

Let me know if you'd like the notebook (`.ipynb`) version or want to include visuals or links to GitHub/Colab.
```