Create Pandas_Series_Vs_NumPy_ndarray.md

Created Pandas_Series_Vs_NumPy_ndarray.md file
Added intro about Pandas series and NumPy ndarray
Added Numpy ndarray section (Intro, key points, Used at)
Added Pandas Series section (Intro, key points, Used at)
pull/207/head
Lingamuneni Santhosh Siddhardha 2024-05-13 14:18:50 +05:30 zatwierdzone przez GitHub
rodzic 229b2a24a4
commit e58671c6a2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 53 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,53 @@
# Pandas Series Vs NumPy ndarray
NumPy ndarray and Pandas Series are two fundamental data structures in Python for handling and manipulating data. While they share some similarities, they also have distinct characteristics that make them suitable for different tasks.
## NumPy ndarray (n-dimensional array)
NumPy is short form for Numerical Python, provides a powerful array object called `ndarray`, which is the backbone of many scientific and mathematical Python libraries.
Here are key points about NumPy `ndarray`:
- **Homogeneous Data**: All elements in a NumPy array are of the same data type, which allows for efficient storage and computation.
- **Efficient Computation**: NumPy arrays are designed for numerical operations and are highly efficient. They support vectorized operations, allowing you to perform operations on entire arrays rather than individual elements.
- **Multi-dimensional**: NumPy arrays can be multi-dimensional, making them suitable for representing complex numerical data structures like matrices and tensors.
Example of creating a NumPy array:
```python
import numpy as np
narr = np.array(['A', 'B', 'C', 'D', 'E'])
print(narr)
```
### Use NumPy ndarray:
- When you need to perform mathematical operations on numerical data.
- When youre working with multi-dimensional data.
- When computational efficiency is important.
## Pandas Series
Pandas, built on top of NumPy, introduces the `Series` data structure, which is designed for handling labeled one-dimensional data efficiently.
Here are the key points about Pandas `Series`:
- **Labeled Data**: Pandas Series associates a label (or index) with each element of the array, making it easier to work with heterogeneous or labeled data.
- **Flexible Data Types**: Unlike NumPy arrays, Pandas Series can hold data of different types (integers, floats, strings, etc.) within the same object.
- **Data Alignment**: One of the powerful features of Pandas Series is its ability to automatically align data based on label. This makes handling and manipulating data much more intuitive and less error-prone.
Example of creating a Pandas Series:
```python
import pandas as pd
series = pd.Series([1, 3, 5, 7, 6, 8])
print(series)
```
### Use Pandas Series:
- When you need to manipulate and analyze labeled data.
- When youre dealing with heterogeneous data or missing values.
- When you need more high-level, flexible data manipulation functions.