Pandas Numpy
Pandas Numpy
Pandas Numpy
Pandas is a Python library used for data manipulation and analysis. It provides data structures
like:
# Select a column
print(df['Name'])
# Filter rows
filtered_df = df[df['Age'] > 28]
print(filtered_df)
1.4 Adding/Updating Columns
# Add a new column
df['Country'] = ['USA', 'UK', 'Canada']
2. What is NumPy?
NumPy (Numerical Python) is a library for numerical computations. It provides support for
arrays, matrices, and mathematical functions.
Installing NumPy
pip install numpy
# Create a 1D array
arr = np.array([1, 2, 3, 4, 5])
print(arr)
# Create a 2D array
matrix = np.array([[1, 2], [3, 4], [5, 6]])
print(matrix)
# Matrix multiplication
result = np.dot(matrix, matrix.T)
print(result)
# Statistical operations
print("Mean:", np.mean(arr))
print("Max:", np.max(arr))
print("Min:", np.min(arr))
2.3 Special Arrays
# Create an array of zeros
zeros = np.zeros((3, 3))
print(zeros)
3. What is Matplotlib?
Matplotlib is a library for creating static, animated, and interactive visualizations in Python.
Installing Matplotlib
pip install matplotlib
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]
plt.scatter(x, y, color='red')
plt.title('Scatter Plot Example')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.show()