Personal tools

Numpy and Pandas

Stanford_University_P1010988
(Stanford University - Jaclyn Chen)

- Overview

NumPy and Pandas are two of the most popular Python libraries for data science. NumPy is a library for working with arrays, while Pandas is a library for working with dataframes.

Python is a versatile, English syntax-based programming language, applicable in various data and mathematical computation situations. It is the fastest-growing programming language today (2024) and boasts over 137,000 libraries. 

NumPy and Pandas are two popular Python libraries often used in data analytics. NumPy excels in creating N-dimension data objects and performing mathematical operations efficiently, while Pandas is renowned for data wrangling and its ability to handle large datasets. 

 

- Examples

Here are some examples of how NumPy and Pandas can be used:

import numpy as np

# Create a NumPy array
arr = np.array([1, 2, 3, 4, 5])

# Print the array
print(arr)

# Perform a mathematical operation on the array
print(arr * 2)


Output:

[1 2 3 4 5]
[2 4 6 8 10]

Use code with caution.
Learn more

import pandas as pd

# Create a Pandas dataframe
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})

# Print the dataframe
print(df)

# Perform a data wrangling operation on the dataframe
print(df.head())

Output:

   A  B
0  1  4
1  2  5
2  3  6

   A  B
0  1  4
1  2  5

 

 

[More to come ...]


 

 

Document Actions