0
0
Data Analysis Pythondata~5 mins

Essential libraries overview (Pandas, NumPy, Matplotlib) in Data Analysis Python

Choose your learning style9 modes available
Introduction

These libraries help you work with data easily. They let you organize, calculate, and show data in simple ways.

You want to read and organize data from files like spreadsheets.
You need to do math or statistics on large sets of numbers.
You want to create charts or graphs to understand data better.
You are cleaning messy data to prepare it for analysis.
You want to explore data quickly to find patterns or trends.
Syntax
Data Analysis Python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

Use pd as a short name for Pandas to save typing.

Use np as a short name for NumPy for easy access to math functions.

Examples
This shows how to make a small table with Pandas and print it.
Data Analysis Python
import pandas as pd

# Create a simple table (DataFrame)
data = pd.DataFrame({'Name': ['Anna', 'Bob'], 'Age': [25, 30]})
print(data)
This creates a list of numbers with NumPy and doubles each number.
Data Analysis Python
import numpy as np

# Create an array of numbers
numbers = np.array([1, 2, 3, 4])
print(numbers * 2)
This draws a line chart with Matplotlib and shows it.
Data Analysis Python
import matplotlib.pyplot as plt

# Make a simple line chart
plt.plot([1, 2, 3], [4, 5, 6])
plt.title('Simple Line Chart')
plt.show()
Sample Program

This program shows how to use Pandas to hold data, NumPy to calculate the average, and Matplotlib to draw a sales chart.

Data Analysis Python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Create a DataFrame with sample data
data = pd.DataFrame({
    'Day': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
    'Sales': [200, 220, 250, 210, 230]
})

# Calculate average sales using NumPy
average_sales = np.mean(data['Sales'])

# Print the data and average
print('Sales Data:')
print(data)
print(f'Average Sales: {average_sales}')

# Plot sales over days
plt.plot(data['Day'], data['Sales'], marker='o')
plt.title('Sales Over Week')
plt.xlabel('Day')
plt.ylabel('Sales')
plt.grid(True)
plt.show()
OutputSuccess
Important Notes

Pandas is great for tables and labels.

NumPy is fast for math with many numbers.

Matplotlib helps you see data with pictures.

Summary

Pandas organizes data in tables.

NumPy does math on numbers quickly.

Matplotlib draws charts to understand data.