From e58671c6a26a99ac03ced86ac7b70dc8b431e32e Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 14:18:50 +0530 Subject: [PATCH 01/10] 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) --- .../pandas/Pandas_Series_Vs_NumPy_ndarray.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md diff --git a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md new file mode 100644 index 0000000..d60a058 --- /dev/null +++ b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md @@ -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 you’re 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 you’re dealing with heterogeneous data or missing values. +- When you need more high-level, flexible data manipulation functions. From a269499c99f46be3d2ac087ff58c1e43888aa09a Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 14:20:18 +0530 Subject: [PATCH 02/10] Update Pandas_Series_Vs_NumPy_ndarray.md Extended Introduction --- contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md index d60a058..e71282b 100644 --- a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md +++ b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md @@ -1,6 +1,9 @@ # 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. + +While both NumPy ndarray and Pandas Series are essential tools for data manipulation in Python, Choosing between them depends on the nature of your data and the specific tasks you need to perform. + ## 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. From f61ceca303eeac22d84684a856a00fcffe18d926 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 14:23:23 +0530 Subject: [PATCH 03/10] Update index.md Added Section title and Link to it --- contrib/pandas/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/pandas/index.md b/contrib/pandas/index.md index 82596a2..cff8136 100644 --- a/contrib/pandas/index.md +++ b/contrib/pandas/index.md @@ -1,3 +1,5 @@ # List of sections +- Pandas Series Vs NumPy ndarray - [Section title](filename.md) +- [Pandas Series Vs NumPy ndarray)(Pandas_Series_Vs_NumPy_ndarray.md) From 33bae7b53f64715fccf0b2b2aa3aae481285eaf1 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 14:24:24 +0530 Subject: [PATCH 04/10] Update index.md --- contrib/pandas/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/pandas/index.md b/contrib/pandas/index.md index cff8136..c21ad57 100644 --- a/contrib/pandas/index.md +++ b/contrib/pandas/index.md @@ -1,5 +1,6 @@ # List of sections - Pandas Series Vs NumPy ndarray -- [Section title](filename.md) -- [Pandas Series Vs NumPy ndarray)(Pandas_Series_Vs_NumPy_ndarray.md) + + +- [Pandas Series Vs NumPy ndarray](Pandas_Series_Vs_NumPy_ndarray.md) From f87701802f2a48d476342096f64eb12e953cfdd7 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 15:33:52 +0530 Subject: [PATCH 05/10] Update Pandas_Series_Vs_NumPy_ndarray.md Added Output for Code Snippets --- .../pandas/Pandas_Series_Vs_NumPy_ndarray.md | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md index e71282b..d493136 100644 --- a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md +++ b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md @@ -2,17 +2,17 @@ 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. -While both NumPy ndarray and Pandas Series are essential tools for data manipulation in Python, Choosing between them depends on the nature of your data and the specific tasks you need to perform. +Both NumPy ndarray and Pandas Series are essential tools for data manipulation in Python, Choosing between them depends on the nature of your data and the specific tasks you need to perform. -## NumPy ndarray (n-dimensional array) +## NumPy ndarray -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. +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. ndarray is also called n-dimensional array. Indexing in ndarray is integer based indexing. -Here are key points about NumPy `ndarray`: +Features of 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. +- **Efficient Computation and Performance**: 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 n-dimensional arrays. Example of creating a NumPy array: @@ -22,21 +22,26 @@ import numpy as np narr = np.array(['A', 'B', 'C', 'D', 'E']) print(narr) ``` -### Use NumPy ndarray: +Output: +```python +['A' 'B' 'C' 'D' 'E'] +``` +### Usage of NumPy ndarray: - When you need to perform mathematical operations on numerical data. - When you’re working with multi-dimensional data. - When computational efficiency is important. +- When you need to store data of same data type. ` ## Pandas Series -Pandas, built on top of NumPy, introduces the `Series` data structure, which is designed for handling labeled one-dimensional data efficiently. +Pandas is a Python library used for data manipulation and analysis, introduces the `Series` data structure, which is designed for handling labeled one-dimensional data efficiently. -Here are the key points about Pandas `Series`: +Features of 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. +- **Heterogeneous Data**: 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. @@ -45,12 +50,23 @@ Example of creating a Pandas Series: ```python import pandas as pd -series = pd.Series([1, 3, 5, 7, 6, 8]) +series = pd.Series([1,'B', 5, 7, 6, 8], index = ['a','b','c','d','e','f']) print(series) ``` +Output: +```python +a 1 +b B +c 5 +d 7 +e 6 +f 8 +dtype: object +``` -### Use Pandas Series: +### Usage of Pandas Series: - When you need to manipulate and analyze labeled data. - When you’re dealing with heterogeneous data or missing values. - When you need more high-level, flexible data manipulation functions. +- When you are dealing with One-dimensional data. From 7cd0ec140e3a036a02b65a366d8336c02a8c016d Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 15:58:31 +0530 Subject: [PATCH 06/10] Update Pandas_Series_Vs_NumPy_ndarray.md --- contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md index d493136..e739766 100644 --- a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md +++ b/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md @@ -6,7 +6,7 @@ Both NumPy ndarray and Pandas Series are essential tools for data manipulation i ## NumPy ndarray -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. ndarray is also called n-dimensional array. Indexing in ndarray is integer based indexing. +NumPy is short form for Numerical Python, provides a powerful array object called `ndarray`, It is very important for many scientific and mathematical Python libraries. ndarray is also called n-dimensional array. Indexing in ndarray is integer based indexing (like arr[0], arr[3], etc.). Features of NumPy `ndarray`: @@ -31,11 +31,11 @@ Output: - When you need to perform mathematical operations on numerical data. - When you’re working with multi-dimensional data. - When computational efficiency is important. -- When you need to store data of same data type. ` +- When you need to store data of same data type. ## Pandas Series -Pandas is a Python library used for data manipulation and analysis, introduces the `Series` data structure, which is designed for handling labeled one-dimensional data efficiently. +Pandas is a Python library used for data manipulation and analysis, introduces the `Series` data structure, which is designed for handling labeled one-dimensional data efficiently. Indexing in Pandas Series is Label-based. It effectively handles heterogeneous data. Features of Pandas `Series`: @@ -43,7 +43,7 @@ Features of Pandas `Series`: - **Heterogeneous Data**: 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. +- **Data Alignment**: One of the powerful features of Pandas Series is its ability to automatically align data based on label. Example of creating a Pandas Series: From d6184b240ea244d8804f450c91bbcca79fa521fe Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 16:04:53 +0530 Subject: [PATCH 07/10] Update index.md --- contrib/pandas/index.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/pandas/index.md b/contrib/pandas/index.md index c21ad57..8c7fa42 100644 --- a/contrib/pandas/index.md +++ b/contrib/pandas/index.md @@ -1,6 +1,3 @@ # List of sections -- Pandas Series Vs NumPy ndarray - - - [Pandas Series Vs NumPy ndarray](Pandas_Series_Vs_NumPy_ndarray.md) From 13bc6d8f3b5af50d9cb6676939e466d7c5e6a1e1 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 17:07:48 +0530 Subject: [PATCH 08/10] Rename Pandas_Series_Vs_NumPy_ndarray.md to pandas_series_Vs_numpy_ndarray.md Renamed file name into lowercase --- ...ries_Vs_NumPy_ndarray.md => pandas_series_Vs_numpy_ndarray.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/pandas/{Pandas_Series_Vs_NumPy_ndarray.md => pandas_series_Vs_numpy_ndarray.md} (100%) diff --git a/contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md b/contrib/pandas/pandas_series_Vs_numpy_ndarray.md similarity index 100% rename from contrib/pandas/Pandas_Series_Vs_NumPy_ndarray.md rename to contrib/pandas/pandas_series_Vs_numpy_ndarray.md From 45f494f9c017ecadbae17e979d16e52fe46d8f07 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 17:08:49 +0530 Subject: [PATCH 09/10] Update index.md Linked properly --- contrib/pandas/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pandas/index.md b/contrib/pandas/index.md index 8c7fa42..5c0f2b4 100644 --- a/contrib/pandas/index.md +++ b/contrib/pandas/index.md @@ -1,3 +1,3 @@ # List of sections -- [Pandas Series Vs NumPy ndarray](Pandas_Series_Vs_NumPy_ndarray.md) +- [Pandas Series Vs NumPy ndarray](pandas_series_vs_numpy_ndarray.md) From 950a3136a0ef4b083b06d36bbef9453186c2add0 Mon Sep 17 00:00:00 2001 From: Lingamuneni Santhosh Siddhardha <103999924+Santhosh-Siddhardha@users.noreply.github.com> Date: Mon, 13 May 2024 17:10:35 +0530 Subject: [PATCH 10/10] Rename pandas_series_Vs_numpy_ndarray.md to pandas_series_vs_numpy_ndarray.md renamed file --- ...ries_Vs_numpy_ndarray.md => pandas_series_vs_numpy_ndarray.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contrib/pandas/{pandas_series_Vs_numpy_ndarray.md => pandas_series_vs_numpy_ndarray.md} (100%) diff --git a/contrib/pandas/pandas_series_Vs_numpy_ndarray.md b/contrib/pandas/pandas_series_vs_numpy_ndarray.md similarity index 100% rename from contrib/pandas/pandas_series_Vs_numpy_ndarray.md rename to contrib/pandas/pandas_series_vs_numpy_ndarray.md