Python Data Manipulation and Analysis

NumPy:

NumPy, which stands for Numerical Python, is a effective open-source library in Python for numerical and mathematical operations.

It affords support for big, multi-dimensional arrays and matrices, along side a group of mathematical features to function on these arrays.

NumPy is a fundamental library for medical computing in Python and serves as the foundation for plenty different libraries in the Python facts technology surroundings.

Installing NumPy:

                                  
                                    pip install numpy
                                  
                                

Basic NumPy Operations:

                                  
                                    import numpy as np

# Creating arrays
arr1 = np.array([1, 2, 3, 4, 5])
arr2 = np.arange(0, 10, 2)  # Array from 0 to 10 (exclusive) with a step of 2

# Operations on arrays
sum_array = arr1 + arr2
product_array = arr1 * arr2

# Universal functions (ufunc)
squared_array = np.square(arr1)
sqrt_array = np.sqrt(arr1)

# Matrix operations
matrix1 = np.array([[1, 2], [3, 4]])
matrix2 = np.array([[5, 6], [7, 8]])
matrix_product = np.dot(matrix1, matrix2)

# Statistics
mean_value = np.mean(arr1)
max_value = np.max(arr1)
min_value = np.min(arr1)
                                  
                                

Pandas:

Pandas is an open-source records manipulation and evaluation library for Python. It affords facts systems for successfully handling huge datasets and gear for running with structured facts. Pandas is built on top of NumPy and is a essential factor of the Python statistics technological know-how environment.

Installing Pandas:

                                  
                                    pip install pandas
                                  
                                

Basic Pandas Operations:

                                  
                                    import pandas as pd

# Creating a DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 22]}
df = pd.DataFrame(data)

# Accessing columns and rows
name_column = df['Name']
age_row = df.loc[1]

# Adding a new column
df['City'] = ['New York', 'San Francisco', 'Los Angeles']

# Filtering data
young_people = df[df['Age'] < 30]

# Grouping and aggregating
mean_age_by_city = df.groupby('City')['Age'].mean()

# Reading from and writing to CSV
df.to_csv('example.csv', index=False)
new_df = pd.read_csv('example.csv')
                                  
                                

Matplotlib:

Matplotlib is a complete facts visualization library for Python. It is broadly used for creating static, animated, and interactive plots in Python. Matplotlib gives quite a few plotting capabilities and gear for visualizing statistics in a clean and effective way.

Installing Matplotlib:

                                  
                                    pip install matplotlib
                                  
                                

Basic Matplotlib Operations:

                                  
                                    import matplotlib.pyplot as plt

# Line plot
x = np.arange(0, 10, 0.1)
y = np.sin(x)
plt.plot(x, y)
plt.title('Sine Wave')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.show()

# Scatter plot
plt.scatter(df['Age'], df['City'])
plt.title('Age Distribution by City')
plt.xlabel('Age')
plt.ylabel('City')
plt.show()
                                  
                                

These examples cover primary operations for information manipulation and evaluation the usage of NumPy, Pandas, and Matplotlib. These libraries are extensively used in the facts technological know-how community and provide green gear for coping with and studying records.